开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
master
分支 (32)
标签 (124)
master
dependabot/maven/org.jenkins-ci.plugins-plugin-6.2189.v695a_c41f5249
dependabot/maven/com.sonyericsson.jenkins.plugins.bfa-build-failure-analyzer-3.887.vc872cf1b_7dff
distributed-storage
dependabot/maven/org.jenkins-ci.plugins-plugin-5.27
dependabot/maven/org.apache.maven.plugins-maven-checkstyle-plugin-3.6.0
dependabot/maven/com.sonymobile.tools.gerrit-gerrit-events-2.22.0
dependabot/maven/io.jenkins.tools.bom-bom-2.426.x-3208.vb_21177d4b_cd9
dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.35.1
dependabot/maven/com.google.code.gson-gson-2.8.9
2.35.x
bump-core-2.289.x
nokia-trigger_cancel_current_patchset
2.22-beta
2.13-maint
findbugs
JENKINS-23152
2.12-beta
2.11-maintenance
build-flow-dsl
3.1971.v217d381e3a_5a_
3.1969.v65d614ec771a_
gerrit-trigger-2.42.0
gerrit-trigger-2.41.1
gerrit-trigger-2.41.0
gerrit-trigger-2.40.0
gerrit-trigger-2.39.4
gerrit-trigger-2.39.3
gerrit-trigger-2.39.2
gerrit-trigger-2.39.1
gerrit-trigger-2.39.0
gerrit-trigger-2.38.1
gerrit-trigger-2.38.0
gerrit-trigger-2.37.0
gerrit-trigger-2.36.1
gerrit-trigger-2.36.0
gerrit-trigger-2.35.4
gerrit-trigger-2.35.3
gerrit-trigger-2.35.2
gerrit-trigger-2.35.1
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (32)
标签 (124)
master
dependabot/maven/org.jenkins-ci.plugins-plugin-6.2189.v695a_c41f5249
dependabot/maven/com.sonyericsson.jenkins.plugins.bfa-build-failure-analyzer-3.887.vc872cf1b_7dff
distributed-storage
dependabot/maven/org.jenkins-ci.plugins-plugin-5.27
dependabot/maven/org.apache.maven.plugins-maven-checkstyle-plugin-3.6.0
dependabot/maven/com.sonymobile.tools.gerrit-gerrit-events-2.22.0
dependabot/maven/io.jenkins.tools.bom-bom-2.426.x-3208.vb_21177d4b_cd9
dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.35.1
dependabot/maven/com.google.code.gson-gson-2.8.9
2.35.x
bump-core-2.289.x
nokia-trigger_cancel_current_patchset
2.22-beta
2.13-maint
findbugs
JENKINS-23152
2.12-beta
2.11-maintenance
build-flow-dsl
3.1971.v217d381e3a_5a_
3.1969.v65d614ec771a_
gerrit-trigger-2.42.0
gerrit-trigger-2.41.1
gerrit-trigger-2.41.0
gerrit-trigger-2.40.0
gerrit-trigger-2.39.4
gerrit-trigger-2.39.3
gerrit-trigger-2.39.2
gerrit-trigger-2.39.1
gerrit-trigger-2.39.0
gerrit-trigger-2.38.1
gerrit-trigger-2.38.0
gerrit-trigger-2.37.0
gerrit-trigger-2.36.1
gerrit-trigger-2.36.0
gerrit-trigger-2.35.4
gerrit-trigger-2.35.3
gerrit-trigger-2.35.2
gerrit-trigger-2.35.1
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (32)
标签 (124)
master
dependabot/maven/org.jenkins-ci.plugins-plugin-6.2189.v695a_c41f5249
dependabot/maven/com.sonyericsson.jenkins.plugins.bfa-build-failure-analyzer-3.887.vc872cf1b_7dff
distributed-storage
dependabot/maven/org.jenkins-ci.plugins-plugin-5.27
dependabot/maven/org.apache.maven.plugins-maven-checkstyle-plugin-3.6.0
dependabot/maven/com.sonymobile.tools.gerrit-gerrit-events-2.22.0
dependabot/maven/io.jenkins.tools.bom-bom-2.426.x-3208.vb_21177d4b_cd9
dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.35.1
dependabot/maven/com.google.code.gson-gson-2.8.9
2.35.x
bump-core-2.289.x
nokia-trigger_cancel_current_patchset
2.22-beta
2.13-maint
findbugs
JENKINS-23152
2.12-beta
2.11-maintenance
build-flow-dsl
3.1971.v217d381e3a_5a_
3.1969.v65d614ec771a_
gerrit-trigger-2.42.0
gerrit-trigger-2.41.1
gerrit-trigger-2.41.0
gerrit-trigger-2.40.0
gerrit-trigger-2.39.4
gerrit-trigger-2.39.3
gerrit-trigger-2.39.2
gerrit-trigger-2.39.1
gerrit-trigger-2.39.0
gerrit-trigger-2.38.1
gerrit-trigger-2.38.0
gerrit-trigger-2.37.0
gerrit-trigger-2.36.1
gerrit-trigger-2.36.0
gerrit-trigger-2.35.4
gerrit-trigger-2.35.3
gerrit-trigger-2.35.2
gerrit-trigger-2.35.1
贡献代码
同步代码
对比差异 通过 Pull Request 同步
同步更新到分支
通过 Pull Request 同步
将会在向当前分支创建一个 Pull
Request,合入后将完成同步
File empty ...
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Gerrit Trigger Plugin

gerrit trigger plugin Gerrit code review for triggering builds when a "patch set" is created.

Set Up

Gerrit access rights

Gerrit has a special access-group "Service Users" for CI systems and other bots. We recommend that you add your jenkins user in Gerrit to this group.

  1. Create the profile through in Gerrit web interface for your Jenkins user, and set up a SSH key for that user.

  2. Gerrit web interface > Browse > Groups > Service Users > Add your jenkins user.

  3. Browse > Repositories > ...​ > Access > Edit

    • Reference: refs/*

      • Read: ALLOW for Service Users

    • Reference: refs/heads/*

      • Label Code-Review: -1, +1 for Service Users

      • Label Verified: -1, +1 for Service Users

:heavy_exclamation_mark:

Before Gerrit v3.3 the CI group was named "Non-Interactive Users".

Administrative Settings

Specify the Gerrit server settings via "Manage Jenkins > Gerrit Trigger"

Fill in the server settings:

Server settings

Click "Test Connection" to verify the connection.

When everything seems ok, save your settings and restart the connection in the "Control" section at the bottom of the page:

server control

There are many more settings for your pleasure, look at the individual help sections for information what they are about.

Trigger Configuration

In the "Build Triggers" section of your Job configuration page; tick "Gerrit event":

Job trigger configuration

Specify what type of event(s) to trigger on:

  • Draft Published: Sent when a change moves from draft state to new. (Support for draft removed in Gerrit v2.15).

  • Patchset Created: Sent when a new patchset arrives on a change.

  • Change Merged: Sent when a change is merged on the Gerrit server.

  • Comment Added: Sent when a comment is added to a change. Which category and value to trigger on can be configured. The available categories can be configured in the server settings for the plugin.

  • Ref Updated: Sent when a ref is updated on the Gerrit server, i.e. someone pushes past code review.

The same syntax works for specifying which file(s) to trigger on (this is only available in version 2.3 or higher of Gerrit).

Dynamic triggering

From version 2.6.0 of the plugin, a new way of configuring what projects, branches and files to trigger on is available.
Dynamic Trigger Configuration By checking the checkbox "Dynamic Trigger Configuration", the user is asked for the URL to a file.

On a set interval, the plugin fetches and parses this file. The file contents should follow this syntax:

p=some/project
b^**/master/*
t~.*
h~.*
f~.*\.txt
p=some/other/project
b^**

Explanation:

p for project
b for branch
t for topic
h for hashtags
f for file
= for plain syntax
^ for ANT style syntax
~ for regexp syntax

Branch and file lines are assumed to be part of the closest preceding project line.

The dynamic triggering can be used in combination with the usual configuration, described above. The gerrit trigger will

trigger both for the dynamic and non-dynamic configurations.

The interval on which Jenkins fetches the file is configurable in the administrative pages for the Gerrit trigger, under advanced:

Dynamic trigger refresh

:information_source:
Anonymous user must have READ permissions to Jobs in order for this feature to work.
Use case

The reason for this functionality is that a user would want to update a list of what to trigger on outside of Jenkins.

Another use case is to run a build in Jenkins periodically that creates the list, then have several projects use the same list.

Gerrit hooks

Gerrit doesn’t use the standard repository hooks. To do an automatic update of jenkins on a patch you’ll need to install the "hooks" plugin and add a hook to the top-level gerrit hook directory ($site_path/hooks).

The equivalent of a git 'post-receive' hook for gerrit is a 'patchset-created' handler. More info on gerrit hooks can be found here:

Usage with the Git Plugin

To get the Git Plugin to download your change; set Refspec to $GERRIT_REFSPEC and the Choosing strategy to Gerrit Trigger. This may be under ''Additional Behaviours/Strategy For Choosing What To Build' rather than directly visible as depicted in the screenshot. You may also need to set 'Branches to build' to $GERRIT_BRANCH. If this does not work for you set Refspec to refs/changes/:refs/changes/* and 'Branches to build' to *$GERRIT_REFSPEC.

:information_source:
Be aware that $GERRIT_BRANCH and $GERRIT_REFSPEC are not set in the Ref Updated case. If you want to trigger a build, you can set Refspec and 'Branches to build' to $GERRIT_REFNAME.

Git Configuration

Usage with Repo

If you are using a freestyle project and repo to download your code it would be as "easy" as.

repo init -u git://gerrit.mycompany.net/mymanifest.git
repo sync
repo download $GERRIT_PROJECT $GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER

Missed Events Playback Feature (Available from v. 2.14.0)

:information_source:
This feature replaces the "Check Non-Reviewed Patchsets" option that was part of a Job’s Gerrit Trigger configuration.

If your Jenkins instance has been down for a period of time (upgrade or maintenance), the Missed Events Playback Feature ensures that any missed events are re-played and builds are triggered.

The mechanics are as follows:

  • The Playback Manager maintains a last known alive timestamp of events that were received by the Gerrit Server connection.

  • Upon re-connect, a request is made to the Gerrit Events-Log plugin installed on the Gerrit Server to determine which events may have been missed while the connection was down.

  • The events are then added to the Gerrit Trigger event queue to be processed.

Setup Requirements

The Playback Manager requires:

  • The REST api to be configured for the Gerrit Server Connection.

  • The Gerrit Events-log plugin must be installed on the Gerrit Server (Please see Setting up the REST api

    • To setup the REST api for the Gerrit Server Connection, navigate to Manage Jenkins > Gerrit Trigger and click on the Edit icon for the Server Connection.

    • Click on Advanced, and enter the Gerrit HTTP User and Gerrit HTTP Password values as shown below.

    Playback REST Api

    • Click on Test REST Connection to verify the user and password settings.

    • Click on Save

    • Restart the connection using the Status icon in the Server Table shown below:

    Restart Gerrit Server connection

Gerrit Server Events-Log plugin

Gerrit Server Events-Log plugin

:information_source:
Please note that if the Gerrit Server Events-Log plugin is not installed on the Gerrit Server, then the Playback Manager will be disabled.
  • Please see Verifying functionality

    • Once you have restarted the connection, click on the Edit icon in the Server Table. If there is a problem with the Playback Manager’s configuration, you will see this:

    Playback Warning

    • If the Playback Manager is correctly setup, you will see the following in the Jenkins log file when the Gerrit Server Connection is started:

    INFO: (8) missed events to process for server: defaultServer ...

Skip Vote

"Skipping" the vote means that if more than one build is triggered by a Gerrit event the outcome of this build that "skips its vote" won’t be counted when the final vote is sent to Gerrit. If this is the only build that is triggered then the vote will be 0.

This can be useful if you have one job that triggers on all patch set created events that just checks that the commit message is correctly formatted, so it should only deny merging if it is a bad commit message but also not allow the merge just because the message was ok. In that scenario you could configure the "check commit message" job to skip voting on Successful.

Additional Screenshots

Badges Retrigger Manual retrigger

Pipeline Jobs

Version 2.15.0 of the Gerrit Trigger plugin supports Jenkins Pipeline job types. So as with the traditional job types, this plugin supports:

  1. Triggering of Pipeline Jobs based on Gerrit Event notifications e.g. the Patchset Created event.

  2. Checkout of the change-set revision from the Gerrit Git repository. See example below.

  3. Sending of the "build completed" command to Gerrit (with Verified label etc).

The plugin doesn’t currently offer a dedicated DSL syntax for performing the change-set checkout. However, it’s very easy to perform the checkout using the Gerrit parameters provided to the build, along with the existing Workflow step for Git (or other supported SCM) e.g.

node {
 // Checkout the Gerrit git repository using the existing
 // workflow git step...
 git url: '<gerrit-git-repo-url>'

 // Fetch the changeset to a local branch using the build parameters provided to the
 // build by the Gerrit plugin...
 def changeBranch = "change-${GERRIT_CHANGE_NUMBER}-${GERRIT_PATCHSET_NUMBER}"
 sh "git fetch origin ${GERRIT_REFSPEC}:${changeBranch}"
 sh "git checkout ${changeBranch}"

 // Build the changeset rev source etc...
}

Note though that with this approach the changelog will not show correctly.

Tips & Tricks

This section contains some useful tips and tricks that users has come up with. Feel free to add your own.

Using "Build Now"

Normally when you have configured a job to be triggered by Gerrit you can’t use the "Build Now" link anymore since your builds are dependent on information from Gerrit, especially if you are using the Git plugin to checkout your code in the workspace.

You can get around this limitation if you for example want to use the same job to build the master branch at some point. If you are using the Git plugin do the following

Add a String parameter called GERRIT_REFSPEC with the default value refs/heads/master

Using this trick will enable you to build, but no results will be sent to Gerrit since it is not triggered by it.

Multiple jobs review the same changeset (possibly giving different answers)

That’s possible, see Reduce number of notification emails

Since the trigger adds a comment in Gerrit for each build start and end, usually all the reviewers get a notification email. This can get quite annoying. However, it’s possible to configure Gerrit so that only the change owner and people who starred the change get a notification email. To do this DENY the 'Email Reviewers' capability for the Gerrit user that is used by Jenkins. See Verified label

You need to ensure that a Verified label is configured in Gerrit, otherwise the Gerrit Trigger will fail to submit votes for jobs, due to the invalid label.

verified voting

Change Log

New releases are logged in CHANGELOG.old.adoc

举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

https://github.com/mamh-java/gerrit-trigger-plugin
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mamh-java/gerrit-trigger-plugin.git
git@gitee.com:mamh-java/gerrit-trigger-plugin.git
mamh-java
gerrit-trigger-plugin
gerrit-trigger-plugin
master
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /