不可自动合并的PR不触发构建,且发送评论到PR中
This commit is contained in:
parent
db047e0f4a
commit
2c5e83f5d0
320
CHANGELOG.md
320
CHANGELOG.md
|
@ -1,320 +0,0 @@
|
||||||
ChangeLog
|
|
||||||
|
|
||||||
1.0 for Gitee plugin
|
|
||||||
=====================
|
|
||||||
* change Gitlab to Gitee
|
|
||||||
* support Gitee api v5
|
|
||||||
|
|
||||||
|
|
||||||
1.5.6
|
|
||||||
=====================
|
|
||||||
* #691: Fix project ID regex to not require '.git' in URLs
|
|
||||||
* #693: Allow sending 'pending' status when Pipeline jobs are in queue
|
|
||||||
* #693: Allow canceling of running MR builds when new commits are pushed to the MR
|
|
||||||
* #759: Fix NPE when saving job config in some cases
|
|
||||||
* #767: Fix NPE when GitLab pipeline event is received
|
|
||||||
|
|
||||||
1.5.5
|
|
||||||
=====================
|
|
||||||
* #698: Make plugin respect no-proxy-hosts when a proxy is used
|
|
||||||
* #731: "Build on successful pipeline events" setting does not stay set
|
|
||||||
* #732: Filtering by label never matches anything
|
|
||||||
|
|
||||||
1.5.4
|
|
||||||
=====================
|
|
||||||
* #714: Fix broken 'Trigger on approved merge requests' setting
|
|
||||||
* #726: Do not build approved merge requests unless configured to do so
|
|
||||||
|
|
||||||
1.5.3
|
|
||||||
=====================
|
|
||||||
* #622: GitlabCommitStatus throws error after force kill
|
|
||||||
* #678: Fixes NPE if GitLab connection fails
|
|
||||||
|
|
||||||
1.5.2
|
|
||||||
=====================
|
|
||||||
* #524: If Blue Ocean is installed, build URL in GitLab will point to Blue Ocean
|
|
||||||
* #564: Build status can now be sent to GitLab from builds downstream of the one that GitLab triggered
|
|
||||||
* #589: Make it easier to distinguish a commit push from a tag push
|
|
||||||
* #616: Make it easier to configure gitlab-plugin from Job DSL plugin.
|
|
||||||
* #639: Don't NPE if one of the filter specs is not specified in a Jenkinsfile
|
|
||||||
* #658: Send current state of build to GitLab when making commit API calls so it can be seen in the GitLab UI
|
|
||||||
* #659: Trigger builds when MR is approved in GitLab
|
|
||||||
|
|
||||||
1.5.1
|
|
||||||
=====================
|
|
||||||
* #648: Fix NPE when an MR build is triggered
|
|
||||||
* #650: Improve GitLab API version autodetection
|
|
||||||
* #653: Fix unsupported date format in MR trigger
|
|
||||||
* #656: Fix 404 error when making v4 API calls for MRs
|
|
||||||
|
|
||||||
1.5.0
|
|
||||||
=====================
|
|
||||||
* #614: Add optional support for GitLab API v4
|
|
||||||
|
|
||||||
1.4.8
|
|
||||||
=====================
|
|
||||||
* #483: If 'Add message for failed builds' feature is used, send the message for both failed and 'unstable' builds
|
|
||||||
* #514: Fix branch name comparison to avoid spurious builds, fixes issue #512
|
|
||||||
* #540: Allow jobs to be triggered by GitLab 'Pipeline' event
|
|
||||||
* #552: Use GitLab's host url to calculate project's ID - allows Jenkins to work with GitLab projects that are in subgroups (issue #538)
|
|
||||||
* #567: Plugin should have secure defaults - first-time installs will now have plugin endpoint require auth by default
|
|
||||||
* #604: Recursively retrieve all BuildData - prevents Jenkins from rebuilding when MR assignee changes (issue #603)
|
|
||||||
|
|
||||||
1.4.7
|
|
||||||
=====================
|
|
||||||
* #584: Fixes commit status exception found in issue #583
|
|
||||||
|
|
||||||
1.4.6
|
|
||||||
=====================
|
|
||||||
* #508 and #542: Trigger build when merge request has been merged or closed
|
|
||||||
* #510: Add gitlabMergeRequestTargetProjectId to available variables in builds
|
|
||||||
* #516: Fix: Trigger for pushes to the destination branch of open merge requests does not work in pipeline scripts
|
|
||||||
* #532: Allow publishing a comment to the GitLab MR if the build result is 'unstable'
|
|
||||||
* #543: Matrix/multi-configuration project support
|
|
||||||
* #544: Add a button to clear the security token in build configuration
|
|
||||||
* #559: Add a function to (re)set the Gitlab connections for bootstrapping new Jenkins installs
|
|
||||||
* #562: Fix issue #523 - Build result sent to Pipeline library repo instead of project repo
|
|
||||||
|
|
||||||
1.4.5
|
|
||||||
=====================
|
|
||||||
* #488: Support Declarative Pipeline job syntax
|
|
||||||
* #503: Don't create spurious 'pending' states in GitLab when updating build status
|
|
||||||
|
|
||||||
1.4.4
|
|
||||||
=====================
|
|
||||||
* #429: Number format is added at merge requests > 1000
|
|
||||||
* #447: Token creation throws exception
|
|
||||||
* #448: When user is not permitted to trigger build there is no information logged
|
|
||||||
* #455: "HTTP 414 Request-URI Too Long" when posting a large note
|
|
||||||
* #470: NPE on merge request web hook
|
|
||||||
|
|
||||||
1.4.3
|
|
||||||
=====================
|
|
||||||
* #407: Added Remove-Accept Encoding Filter, to resolve occasional issues with data sent from GitLab
|
|
||||||
|
|
||||||
1.4.2
|
|
||||||
=====================
|
|
||||||
* #408: Multiple branches pushed, Only one job triggered
|
|
||||||
|
|
||||||
1.4.1
|
|
||||||
=====================
|
|
||||||
* #410: `NoStaplerConstructorException` for `addGitLabMRComment`
|
|
||||||
* Use plugin ClassLoader for the resteasy client instead of the uberClassLoader
|
|
||||||
* #406: Add include/exclude of merge requests based on gitlab merge request labels
|
|
||||||
* Add possibility to configure secret tokens per job to allow only web hooks with the correct token to trigger builds
|
|
||||||
* #415: Add actual trigger phrase as environment variable
|
|
||||||
|
|
||||||
1.4.0
|
|
||||||
=====================
|
|
||||||
* Breaking changes for some Pipeline jobs (see [migration guide](https://github.com/jenkinsci/gitlab-plugin/wiki/Migration-Guides) for more information)
|
|
||||||
* Cleanup UI for GitLabPushTrigger
|
|
||||||
* #201: customize notes for merge requsts
|
|
||||||
* #168: MR Voting Broken after Gitlab 8.2
|
|
||||||
* #190: Add option to mark unstable builds as success in GitLab
|
|
||||||
* #345: Configurable "Add note with build status on merge requests"
|
|
||||||
* Add Notifier and workflow step for accepting a MR on success
|
|
||||||
* Add workflow step for adding comments to a MR
|
|
||||||
|
|
||||||
1.3.2
|
|
||||||
=====================
|
|
||||||
* JENKINS-36863: Credentials drop-down doesn't show API token credential! (finally fixed it)
|
|
||||||
* #402: Web hooks not triggering build in v1.3.1, Jenkins 2.20
|
|
||||||
* #404: NullPointerException with gitlab ce 8.11
|
|
||||||
|
|
||||||
1.3.1
|
|
||||||
=====================
|
|
||||||
* JENKINS-36863: Credentials drop-down doesn't show API token credential!
|
|
||||||
* #299: Upgrading the plugin sometimes causes loss of configuration
|
|
||||||
* #382: Outgoing HTTP Proxy support in gitlab-plugin
|
|
||||||
* #383: Pipeline - "Pending" Jobs for all stages
|
|
||||||
* #69: Link to gitlab merge request url in getShortDescription posted to jenkins
|
|
||||||
* #396: Jenkins job stuck publishing build status
|
|
||||||
* #400: Fix gitlabBuilds step to actually use 'pending'
|
|
||||||
* JENKINS-35258: ci-skip and author should use the latest commit, not the first one from the push event
|
|
||||||
|
|
||||||
1.3.0
|
|
||||||
=====================
|
|
||||||
* Drop official support for GitLab 7.14 -> no guarantee that new features will work for this version
|
|
||||||
* #298: Pipeline Multibranch builds are not supported
|
|
||||||
* #374/JENKINS-36347: Status publisher not updating status when "Merge before build" (git) fails
|
|
||||||
|
|
||||||
1.2.5
|
|
||||||
=====================
|
|
||||||
* #361: Avoid rebuild merge request if assignee changes
|
|
||||||
* #366: Jenkins can't install plugin
|
|
||||||
|
|
||||||
1.2.4
|
|
||||||
=====================
|
|
||||||
* #332: Find better fitting labels for the supported kind of GitLab credentials in global configuration
|
|
||||||
* #261: Support [WIP] tag to prevent builds from triggering
|
|
||||||
* #317: Retried builds are not marked immediately with Gitlab 8.1
|
|
||||||
* #306: GitLab [ci-skip] is ignored
|
|
||||||
* #362: Allow to change build name submitted to GitLab
|
|
||||||
* Catch client exceptions while retrieving the projectId from GitLab
|
|
||||||
* #358: Null pointer exception when using 'rebuild open MRs' and GitLab 7.14
|
|
||||||
* #364: gitlabCommitStatus: Gitlab in non-root location
|
|
||||||
* #213: Trigger build by phrase in merge request note
|
|
||||||
* #282: Authentication not required for /project end-point
|
|
||||||
* #359: Git repositories in dockerized GitLab cannot be reached from Jenkins when using plugin-provided url parameters
|
|
||||||
* JENKINS-35538: Update credentials-plugin to version 2.1.0
|
|
||||||
* #357: gitlabCommitStatus usage not clear
|
|
||||||
* #349: Fix NPE when updating commit status
|
|
||||||
* #342: Timeout when "Add note with build status on merge requests" runs
|
|
||||||
* Catch also ProcessingExceptions while using the GitLab client
|
|
||||||
* Change order of steps add note and accept MR
|
|
||||||
* #335: More tests and refactoring of ActionResolver.onPost
|
|
||||||
|
|
||||||
1.2.3
|
|
||||||
=====================
|
|
||||||
* #294 Fix: Do not trigger a build for remove branch push event
|
|
||||||
* #246, #290 Add gitlabMergeRequestIid, gitlabSourceNamespace and gitlabTargetNamespace to CauseData and show the correct MR id within the build description
|
|
||||||
* #281 Fix: Builds not be triggered on tag push events
|
|
||||||
* #304 Utilizing SpringUtils to safely perform string comparison
|
|
||||||
* #308 Use the character encoding of the request or UTF-8 if no character encoding is available for decoding the request body of a web hook
|
|
||||||
* #311 Fix finding related commit of the build
|
|
||||||
* #312 Fix setting MR IID
|
|
||||||
* #319: Wrong username in Jenkins build description on push event
|
|
||||||
* #322 Git push hook namespace compatibility for Gitlab pre ~v8.5
|
|
||||||
* #327 Fix to support NameSpace or ProjectName with dot in it
|
|
||||||
* Update tests for new commit status publisher behavior
|
|
||||||
* Use HTTP Get instead of HEAD to check for the existence of a commit as workaround for RESTEASY-1347
|
|
||||||
* Fix: HTTP 404 error for the rebuild open MRs on push to target branch for forked repositories
|
|
||||||
* Update list of variables available in builds
|
|
||||||
* Add notes to README about known Pipeline bugs
|
|
||||||
* Use ResteasyClientBuilder to configure ignoreCertificateErrors
|
|
||||||
* Configure connection pooling and timeouts for the client
|
|
||||||
* Docker: Update Jenkins version to 2.3
|
|
||||||
* Readme: Fix contents links
|
|
||||||
* Readme: Update branch name filtering section
|
|
||||||
* Readme: Add note on gitlab hook values injection
|
|
||||||
* Readme: Add known bugs section
|
|
||||||
* Readme: Note Jenkins parameter security update that can cause problems
|
|
||||||
* Readme: Explain how to add the GitLab API key as a credential.
|
|
||||||
|
|
||||||
1.2.2
|
|
||||||
=====================
|
|
||||||
* #283 Send thumbs-down icon when build fails
|
|
||||||
* #284 NullPointerException when using the GitLabCommitStatusPublisher
|
|
||||||
* Use jenkins credentials-plugin for storing the GitLab API Token
|
|
||||||
* Clear clients cache if connection config has changed
|
|
||||||
* Add workflow step that updates the GitLab commit status depending on the build status
|
|
||||||
|
|
||||||
1.2.1
|
|
||||||
=====================
|
|
||||||
* #271 Version 1.2.0 breaks support for Workflow/Pipeline jobs
|
|
||||||
* **This version of the plugin is incompatible with earlier versions if you are using Pipeline jobs!** You will need to manually change your job configurations. Please see the README section on using the plugin with Pipeline for more information about this.
|
|
||||||
* #275 Handle GitLab API deprecations >= 8.5.0
|
|
||||||
|
|
||||||
1.2.0
|
|
||||||
=====================
|
|
||||||
* #217 Inconsistent code formatting
|
|
||||||
* #212 branch names with non-URL safe characters
|
|
||||||
* #211 Provide useful values of the Push and MR events as build variables
|
|
||||||
* #210 Listen for update MR events instead of push events to rebuild open MRs
|
|
||||||
* #203 Use JAX-RS and resteasy for implementing the GitLab API
|
|
||||||
* #179 NPE if description of MR event is null
|
|
||||||
* #175 Retrieve author name from MR event 'last_commit'
|
|
||||||
* #162 Build status for first push to new branch does not get reported to GitLab
|
|
||||||
* #159 Utilize "not_found" state for GitLab CI Merge Status page
|
|
||||||
* #136 gitlabSourceRepoURL from hook request
|
|
||||||
* #121 Configure GitLab host url and API token at job level
|
|
||||||
* #77 "Ignore SSL Certificate Errors" has no effect
|
|
||||||
* #231 Cleanup GitLabWebHook
|
|
||||||
* #230 Add functionality to configure multiple gitlab connections
|
|
||||||
* #229 Add publisher to update the commit/merge request status in GitLab
|
|
||||||
* #228 Cleanup GitLabPushTrigger
|
|
||||||
|
|
||||||
1.1.32
|
|
||||||
=====================
|
|
||||||
* #218 license within pom.xml and LICENSE is different
|
|
||||||
* #226 Add description to parameters actions
|
|
||||||
* #216 Fix NPE when author email is not available
|
|
||||||
* #235 mention required permissions for commit status API
|
|
||||||
* #225 Enhance README section Contribution
|
|
||||||
* #236 Fix the usage of CommitStatus
|
|
||||||
* #215 Fix error "failed to communicate with gitlab server ..." when try to rebuild open MRs
|
|
||||||
|
|
||||||
1.1.30 + 1.1.31
|
|
||||||
=====================
|
|
||||||
* issues with the release plugin
|
|
||||||
|
|
||||||
1.1.29
|
|
||||||
=====================
|
|
||||||
* #127 Added support for the GitLab 8.1 commit API
|
|
||||||
* #128 Add two variables gitlabUserName and gitlabUserEmail
|
|
||||||
* #129 Assorted minor fixes for merge requests
|
|
||||||
* #139 Fix for issue #125: use reponame for branch caching
|
|
||||||
* #140 Added missing documentation 8.1 CI features
|
|
||||||
* #141 Refactoring data objects to own package
|
|
||||||
* #146 Fixed Documentation after #128
|
|
||||||
* #149 New feature: Add support for regex based filtering and more
|
|
||||||
* #151 Update readme to reflect support for the commit status API
|
|
||||||
* #154 8.1 is now a supported version
|
|
||||||
* #163 Bugfix for issue #160: allow merge requests to different branches from one commit
|
|
||||||
* #164 Not reporting build status 8.1+
|
|
||||||
* #180 Parameter gitlabMergeRequestTitle is always blank
|
|
||||||
* #182 Status to canceled instead of failed if Jenkins build is aborted
|
|
||||||
* #195 Fix NPE if there is no assignee of the MR
|
|
||||||
* #197 Reorganize README to be more clear about config for different versions of GitLab
|
|
||||||
* #205 closes #183 Plugin not working with multiple SCM configuration
|
|
||||||
* #206 Fix Jenkins Workflow support in build trigger code
|
|
||||||
* #209 Don't ignore push builds when responding to status query
|
|
||||||
|
|
||||||
1.1.28
|
|
||||||
=====================
|
|
||||||
* (#119 - @mfriedenhagen) Add buildUrl in the description of the merge (shown in GitLab)
|
|
||||||
* (#124 - @jsyrjala) Fix acceptMergeRequestOnSuccess configuration so it stays set, and is disabled by default
|
|
||||||
* (#127 and #134 - @thommy101) Added support for the GitLab 8.1 commit API
|
|
||||||
* (#133 - @EmteZogaf) Send commit status on push-triggered merge request build
|
|
||||||
|
|
||||||
1.1.27
|
|
||||||
=====================
|
|
||||||
* (#118 - @christ66) IntelliJ Excludes
|
|
||||||
* (#117 - @christ66) Ball Color Changed to Result
|
|
||||||
* (#110 - @kasper-f) Accept Merge Request On Build Succes
|
|
||||||
* (#106 - @xathien) Null Pointer Error Fix
|
|
||||||
* (#105 - @jr4) Merge Request Not Built On First Raise
|
|
||||||
|
|
||||||
1.1.26
|
|
||||||
=====================
|
|
||||||
* (#101 - @TomAndrews) Generalise ci-skip
|
|
||||||
* (#102 - @TomAndrews) Configurable Rebuild Options
|
|
||||||
|
|
||||||
1.1.4
|
|
||||||
=====================
|
|
||||||
* Updated git-plugin dependency to latest version; minimum supported version of Jenkins is now 1.568
|
|
||||||
* Rebuild open merge requests after a push to the source branch (configurable parameter) (kasper-f)
|
|
||||||
* Build page link on Merge Request page redirects to the correct build (zenovich)
|
|
||||||
* Stop building closed merge requests
|
|
||||||
* Bug fixes and documentation updates
|
|
||||||
|
|
||||||
1.1.2
|
|
||||||
=====================
|
|
||||||
* Filter source branches (for push requests only)
|
|
||||||
* Show build status images when Jenkins authentication is on
|
|
||||||
|
|
||||||
1.1.1
|
|
||||||
=====================
|
|
||||||
* Support for Merge Requests from forked repositories
|
|
||||||
* Selective triggering (Push events and/or Merge Request events)
|
|
||||||
|
|
||||||
1.0.8
|
|
||||||
=====================
|
|
||||||
* Fix images not showing up. (Jotschi)
|
|
||||||
* Supprting nested groups with CloudBees Plugin (FrantaM)
|
|
||||||
|
|
||||||
1.0.7
|
|
||||||
=====================
|
|
||||||
* Initial Release
|
|
||||||
|
|
||||||
1.0.2 - 1.0.6
|
|
||||||
=====================
|
|
||||||
* Trying to figure out releases
|
|
||||||
|
|
||||||
1.0.1
|
|
||||||
=====================
|
|
||||||
* Changed Parameter names that were used by default by jenkins.
|
|
||||||
|
|
||||||
1.0
|
|
||||||
=====================
|
|
||||||
* Initial Release
|
|
12
README.md
12
README.md
|
@ -14,12 +14,12 @@
|
||||||
- [Freestyle jobs](#freestyle-jobs-1)
|
- [Freestyle jobs](#freestyle-jobs-1)
|
||||||
- [Advanced features](#advanced-features)
|
- [Advanced features](#advanced-features)
|
||||||
- [Branch filtering](#branch-filtering)
|
- [Branch filtering](#branch-filtering)
|
||||||
- [Add a note to merge requests](#add-a-note-to-merge-requests)
|
- [Add a note to pull requests](#add-a-note-to-merge-requests)
|
||||||
- [Release Workflow](#release-workflow)
|
- [Release Workflow](#release-workflow)
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
This plugin allows Gitee to trigger builds in Jenkins when code is committed or merge requests are opened/updated. It can also send build status back to Gitee.
|
This plugin allows Gitee to trigger builds in Jenkins when code is committed or pull requests are opened/updated. It can also send build status back to Gitee.
|
||||||
|
|
||||||
### Seeking maintainers
|
### Seeking maintainers
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ When you configure the plugin to trigger your Jenkins job, by following the inst
|
||||||
* Select *Build when a change is pushed to Gitee*
|
* Select *Build when a change is pushed to Gitee*
|
||||||
* Copy the *Gitee webhook URL* shown in the UI (see [here](#webhook-url) for guidance)
|
* Copy the *Gitee webhook URL* shown in the UI (see [here](#webhook-url) for guidance)
|
||||||
* Use the check boxes to trigger builds on *Push Events* and/or *Created Pull Request Events* and/or *Accepted Pull Request Events* and/or *Closed Pull Request Events*
|
* Use the check boxes to trigger builds on *Push Events* and/or *Created Pull Request Events* and/or *Accepted Pull Request Events* and/or *Closed Pull Request Events*
|
||||||
* Optionally use *Rebuild open Pull Requests* to enable re-building open merge requests after a push to the source branch
|
* Optionally use *Rebuild open Pull Requests* to enable re-building open pull requests after a push to the source branch
|
||||||
* If you selected *Rebuild open Pull Requests* other than *None*, check *Comments*, and specify the *Comment for triggering a build*. A new build will be triggered when this phrase appears in a commit comment. In addition to a literal phrase, you can also specify a Java regular expression
|
* If you selected *Rebuild open Pull Requests* other than *None*, check *Comments*, and specify the *Comment for triggering a build*. A new build will be triggered when this phrase appears in a commit comment. In addition to a literal phrase, you can also specify a Java regular expression
|
||||||
2. Configure any other pre build, build or post build actions as necessary
|
2. Configure any other pre build, build or post build actions as necessary
|
||||||
3. Click *Save* to preserve your changes in Jenkins
|
3. Click *Save* to preserve your changes in Jenkins
|
||||||
|
@ -117,7 +117,7 @@ When you configure the plugin to trigger your Jenkins job, by following the inst
|
||||||
|
|
||||||
|
|
||||||
## Build status configuration
|
## Build status configuration
|
||||||
You can optionally have your Jenkins jobs send their build status back to Gitee, where it will be displayed in the commit or merge request UI as appropriate.
|
You can optionally have your Jenkins jobs send their build status back to Gitee, where it will be displayed in the commit or pull request UI as appropriate.
|
||||||
|
|
||||||
### Freestyle jobs
|
### Freestyle jobs
|
||||||
Freestyle jobs can only send build status after the build steps are complete. To do this, choose 'Publish build status to Gitee' from the available 'Post-build actions' in your Jenkins job config. Also make sure you have chosen the appropriate Gitee instance from the 'Gitee connection' dropdown menu, if you have more than one.
|
Freestyle jobs can only send build status after the build steps are complete. To do this, choose 'Publish build status to Gitee' from the available 'Post-build actions' in your Jenkins job config. Also make sure you have chosen the appropriate Gitee instance from the 'Gitee connection' dropdown menu, if you have more than one.
|
||||||
|
@ -130,8 +130,8 @@ Triggers may be filtered based on the branch name, i.e. the build will only be a
|
||||||
**Note:** This functionality requires access to Gitee and a git repository url already saved in the project configuration. In other words, when creating a new project, the configuration needs to be saved *once* before being able to add branch filters. For Pipeline jobs, the configuration must be saved *and* the job must be run once before the list is populated.
|
**Note:** This functionality requires access to Gitee and a git repository url already saved in the project configuration. In other words, when creating a new project, the configuration needs to be saved *once* before being able to add branch filters. For Pipeline jobs, the configuration must be saved *and* the job must be run once before the list is populated.
|
||||||
|
|
||||||
|
|
||||||
## Add a note to merge requests
|
## Add a note to pull requests
|
||||||
To add a note to Gitee merge requests after the build completes, select 'Add note with build status on Gitee merge requests' from the optional Post-build actions. Optionally, click the 'Advanced' button to customize the content of the note depending on the build result.
|
To add a note to Gitee pull requests after the build completes, select 'Add note with build status on Gitee pull requests' from the optional Post-build actions. Optionally, click the 'Advanced' button to customize the content of the note depending on the build result.
|
||||||
|
|
||||||
|
|
||||||
# Release Workflow
|
# Release Workflow
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -16,7 +16,7 @@
|
||||||
<artifactId>gitee</artifactId>
|
<artifactId>gitee</artifactId>
|
||||||
<version>1.0.12-SNAPSHOT</version>
|
<version>1.0.12-SNAPSHOT</version>
|
||||||
<name>Gitee Plugin</name>
|
<name>Gitee Plugin</name>
|
||||||
<description>This plugin integrates Gitee to Jenkins by faking a Gitee CI Server. This plugin allows Gitee to trigger builds in Jenkins when code is committed or merge requests are opened/updated. It can also send build status back to Gitee.</description>
|
<description>This plugin integrates Gitee to Jenkins by faking a Gitee CI Server. This plugin allows Gitee to trigger builds in Jenkins when code is committed or pull requests are opened/updated. It can also send build status back to Gitee.</description>
|
||||||
<url>https://wiki.jenkins.io/display/JENKINS/Gitee+Plugin</url>
|
<url>https://wiki.jenkins.io/display/JENKINS/Gitee+Plugin</url>
|
||||||
<packaging>hpi</packaging>
|
<packaging>hpi</packaging>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.gitee.jenkins.cause;
|
package com.gitee.jenkins.cause;
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import hudson.markup.EscapedMarkupFormatter;
|
import hudson.markup.EscapedMarkupFormatter;
|
||||||
import jenkins.model.Jenkins;
|
import jenkins.model.Jenkins;
|
||||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||||
|
@ -31,14 +31,14 @@ public final class CauseData {
|
||||||
private final String sourceRepoUrl;
|
private final String sourceRepoUrl;
|
||||||
private final String sourceRepoSshUrl;
|
private final String sourceRepoSshUrl;
|
||||||
private final String sourceRepoHttpUrl;
|
private final String sourceRepoHttpUrl;
|
||||||
private final String mergeRequestTitle;
|
private final String pullRequestTitle;
|
||||||
private final String mergeRequestDescription;
|
private final String pullRequestDescription;
|
||||||
private final Integer mergeRequestId;
|
private final Integer pullRequestId;
|
||||||
private final Integer mergeRequestIid;
|
private final Integer pullRequestIid;
|
||||||
private final String mergeRequestState;
|
private final String pullRequestState;
|
||||||
private final String mergedByUser;
|
private final String mergedByUser;
|
||||||
private final String mergeRequestAssignee;
|
private final String pullRequestAssignee;
|
||||||
private final Integer mergeRequestTargetProjectId;
|
private final Integer pullRequestTargetProjectId;
|
||||||
private final String targetBranch;
|
private final String targetBranch;
|
||||||
private final String targetRepoName;
|
private final String targetRepoName;
|
||||||
private final String targetNamespace;
|
private final String targetNamespace;
|
||||||
|
@ -63,10 +63,10 @@ public final class CauseData {
|
||||||
@GeneratePojoBuilder(withFactoryMethod = "*")
|
@GeneratePojoBuilder(withFactoryMethod = "*")
|
||||||
CauseData(ActionType actionType, Integer sourceProjectId, Integer targetProjectId, String branch, String sourceBranch, String userName,
|
CauseData(ActionType actionType, Integer sourceProjectId, Integer targetProjectId, String branch, String sourceBranch, String userName,
|
||||||
String userEmail, String sourceRepoHomepage, String sourceRepoName, String sourceNamespace, String sourceRepoUrl,
|
String userEmail, String sourceRepoHomepage, String sourceRepoName, String sourceNamespace, String sourceRepoUrl,
|
||||||
String sourceRepoSshUrl, String sourceRepoHttpUrl, String mergeRequestTitle, String mergeRequestDescription, Integer mergeRequestId,
|
String sourceRepoSshUrl, String sourceRepoHttpUrl, String pullRequestTitle, String pullRequestDescription, Integer pullRequestId,
|
||||||
Integer mergeRequestIid, Integer mergeRequestTargetProjectId, String targetBranch, String targetRepoName, String targetNamespace, String targetRepoSshUrl,
|
Integer pullRequestIid, Integer pullRequestTargetProjectId, String targetBranch, String targetRepoName, String targetNamespace, String targetRepoSshUrl,
|
||||||
String targetRepoHttpUrl, String triggeredByUser, String before, String after, String lastCommit, String targetProjectUrl,
|
String targetRepoHttpUrl, String triggeredByUser, String before, String after, String lastCommit, String targetProjectUrl,
|
||||||
String triggerPhrase, String mergeRequestState, String mergedByUser, String mergeRequestAssignee, String ref, String isTag,
|
String triggerPhrase, String pullRequestState, String mergedByUser, String pullRequestAssignee, String ref, String isTag,
|
||||||
String sha, String beforeSha, String status, String stages, String createdAt, String finishedAt, String buildDuration, String pathWithNamespace) {
|
String sha, String beforeSha, String status, String stages, String createdAt, String finishedAt, String buildDuration, String pathWithNamespace) {
|
||||||
this.actionType = checkNotNull(actionType, "actionType must not be null.");
|
this.actionType = checkNotNull(actionType, "actionType must not be null.");
|
||||||
this.sourceProjectId = checkNotNull(sourceProjectId, "sourceProjectId must not be null.");
|
this.sourceProjectId = checkNotNull(sourceProjectId, "sourceProjectId must not be null.");
|
||||||
|
@ -81,14 +81,14 @@ public final class CauseData {
|
||||||
this.sourceRepoUrl = sourceRepoUrl == null ? sourceRepoSshUrl : sourceRepoUrl;
|
this.sourceRepoUrl = sourceRepoUrl == null ? sourceRepoSshUrl : sourceRepoUrl;
|
||||||
this.sourceRepoSshUrl = checkNotNull(sourceRepoSshUrl, "sourceRepoSshUrl must not be null.");
|
this.sourceRepoSshUrl = checkNotNull(sourceRepoSshUrl, "sourceRepoSshUrl must not be null.");
|
||||||
this.sourceRepoHttpUrl = checkNotNull(sourceRepoHttpUrl, "sourceRepoHttpUrl must not be null.");
|
this.sourceRepoHttpUrl = checkNotNull(sourceRepoHttpUrl, "sourceRepoHttpUrl must not be null.");
|
||||||
this.mergeRequestTitle = checkNotNull(mergeRequestTitle, "mergeRequestTitle must not be null.");
|
this.pullRequestTitle = checkNotNull(pullRequestTitle, "pullRequestTitle must not be null.");
|
||||||
this.mergeRequestDescription = mergeRequestDescription == null ? "" : mergeRequestDescription;
|
this.pullRequestDescription = pullRequestDescription == null ? "" : pullRequestDescription;
|
||||||
this.mergeRequestId = mergeRequestId;
|
this.pullRequestId = pullRequestId;
|
||||||
this.mergeRequestIid = mergeRequestIid;
|
this.pullRequestIid = pullRequestIid;
|
||||||
this.mergeRequestState = mergeRequestState == null ? "" : mergeRequestState;
|
this.pullRequestState = pullRequestState == null ? "" : pullRequestState;
|
||||||
this.mergedByUser = mergedByUser == null ? "" : mergedByUser;
|
this.mergedByUser = mergedByUser == null ? "" : mergedByUser;
|
||||||
this.mergeRequestAssignee = mergeRequestAssignee == null ? "" : mergeRequestAssignee;
|
this.pullRequestAssignee = pullRequestAssignee == null ? "" : pullRequestAssignee;
|
||||||
this.mergeRequestTargetProjectId = mergeRequestTargetProjectId;
|
this.pullRequestTargetProjectId = pullRequestTargetProjectId;
|
||||||
this.targetBranch = checkNotNull(targetBranch, "targetBranch must not be null.");
|
this.targetBranch = checkNotNull(targetBranch, "targetBranch must not be null.");
|
||||||
this.targetRepoName = checkNotNull(targetRepoName, "targetRepoName must not be null.");
|
this.targetRepoName = checkNotNull(targetRepoName, "targetRepoName must not be null.");
|
||||||
this.targetNamespace = checkNotNull(targetNamespace, "targetNamespace must not be null.");
|
this.targetNamespace = checkNotNull(targetNamespace, "targetNamespace must not be null.");
|
||||||
|
@ -97,7 +97,9 @@ public final class CauseData {
|
||||||
this.triggeredByUser = checkNotNull(triggeredByUser, "triggeredByUser must not be null.");
|
this.triggeredByUser = checkNotNull(triggeredByUser, "triggeredByUser must not be null.");
|
||||||
this.before = before == null ? "" : before;
|
this.before = before == null ? "" : before;
|
||||||
this.after = after == null ? "" : after;
|
this.after = after == null ? "" : after;
|
||||||
this.lastCommit = checkNotNull(lastCommit, "lastCommit must not be null");
|
// this.lastCommit = checkNotNull(lastCommit, "lastCommit must not be null");
|
||||||
|
// 直接checkout到分支,而非commit sha,暂时不需要确保lastCommit 非空
|
||||||
|
this.lastCommit = lastCommit;
|
||||||
this.targetProjectUrl = targetProjectUrl;
|
this.targetProjectUrl = targetProjectUrl;
|
||||||
this.triggerPhrase = triggerPhrase;
|
this.triggerPhrase = triggerPhrase;
|
||||||
this.ref = ref;
|
this.ref = ref;
|
||||||
|
@ -125,15 +127,15 @@ public final class CauseData {
|
||||||
variables.put("giteeSourceRepoURL", sourceRepoUrl);
|
variables.put("giteeSourceRepoURL", sourceRepoUrl);
|
||||||
variables.put("giteeSourceRepoSshUrl", sourceRepoSshUrl);
|
variables.put("giteeSourceRepoSshUrl", sourceRepoSshUrl);
|
||||||
variables.put("giteeSourceRepoHttpUrl", sourceRepoHttpUrl);
|
variables.put("giteeSourceRepoHttpUrl", sourceRepoHttpUrl);
|
||||||
variables.put("giteeMergeRequestTitle", mergeRequestTitle);
|
variables.put("giteePullRequestTitle", pullRequestTitle);
|
||||||
variables.put("giteeMergeRequestDescription", mergeRequestDescription);
|
variables.put("giteePullRequestDescription", pullRequestDescription);
|
||||||
variables.put("giteeMergeRequestId", mergeRequestId == null ? "" : mergeRequestId.toString());
|
variables.put("giteePullRequestId", pullRequestId == null ? "" : pullRequestId.toString());
|
||||||
variables.put("giteeMergeRequestIid", mergeRequestIid == null ? "" : mergeRequestIid.toString());
|
variables.put("giteePullRequestIid", pullRequestIid == null ? "" : pullRequestIid.toString());
|
||||||
variables.put("giteeMergeRequestTargetProjectId", mergeRequestTargetProjectId == null ? "" : mergeRequestTargetProjectId.toString());
|
variables.put("giteePullRequestTargetProjectId", pullRequestTargetProjectId == null ? "" : pullRequestTargetProjectId.toString());
|
||||||
variables.put("giteeMergeRequestLastCommit", lastCommit);
|
variables.put("giteePullRequestLastCommit", lastCommit);
|
||||||
variables.putIfNotNull("giteeMergeRequestState", mergeRequestState);
|
variables.putIfNotNull("giteePullRequestState", pullRequestState);
|
||||||
variables.putIfNotNull("giteeMergedByUser", mergedByUser);
|
variables.putIfNotNull("giteeMergedByUser", mergedByUser);
|
||||||
variables.putIfNotNull("giteeMergeRequestAssignee", mergeRequestAssignee);
|
variables.putIfNotNull("giteePullRequestAssignee", pullRequestAssignee);
|
||||||
variables.put("giteeTargetBranch", targetBranch);
|
variables.put("giteeTargetBranch", targetBranch);
|
||||||
variables.put("giteeTargetRepoName", targetRepoName);
|
variables.put("giteeTargetRepoName", targetRepoName);
|
||||||
variables.put("giteeTargetNamespace", targetNamespace);
|
variables.put("giteeTargetNamespace", targetNamespace);
|
||||||
|
@ -206,26 +208,26 @@ public final class CauseData {
|
||||||
return sourceRepoHttpUrl;
|
return sourceRepoHttpUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMergeRequestTitle() {
|
public String getPullRequestTitle() {
|
||||||
return mergeRequestTitle;
|
return pullRequestTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMergeRequestDescription() {
|
public String getPullRequestDescription() {
|
||||||
return mergeRequestDescription;
|
return pullRequestDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPathWithNamespace() { return pathWithNamespace; }
|
public String getPathWithNamespace() { return pathWithNamespace; }
|
||||||
|
|
||||||
public Integer getMergeRequestId() {
|
public Integer getPullRequestId() {
|
||||||
return mergeRequestId;
|
return pullRequestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMergeRequestIid() {
|
public Integer getPullRequestIid() {
|
||||||
return mergeRequestIid;
|
return pullRequestIid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMergeRequestTargetProjectId() {
|
public Integer getPullRequestTargetProjectId() {
|
||||||
return mergeRequestTargetProjectId;
|
return pullRequestTargetProjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTargetBranch() {
|
public String getTargetBranch() {
|
||||||
|
@ -291,25 +293,25 @@ public final class CauseData {
|
||||||
return actionType.getShortDescription(this);
|
return actionType.getShortDescription(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMergeRequestState() {
|
public String getPullRequestState() {
|
||||||
return mergeRequestState;
|
return pullRequestState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMergedByUser() {
|
public String getMergedByUser() {
|
||||||
return mergedByUser;
|
return mergedByUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMergeRequestAssignee() {
|
public String getPullRequestAssignee() {
|
||||||
return mergeRequestAssignee;
|
return pullRequestAssignee;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MergeRequest getMergeRequest() {
|
public PullRequest getPullRequest() {
|
||||||
if (mergeRequestId == null) {
|
if (pullRequestId == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MergeRequest(mergeRequestId, mergeRequestIid, sourceBranch, targetBranch, mergeRequestTitle,
|
return new PullRequest(pullRequestId, pullRequestIid, sourceBranch, targetBranch, pullRequestTitle,
|
||||||
sourceProjectId, targetProjectId, mergeRequestDescription, mergeRequestState, pathWithNamespace);
|
sourceProjectId, targetProjectId, pullRequestDescription, pullRequestState, pathWithNamespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -335,14 +337,14 @@ public final class CauseData {
|
||||||
.append(sourceRepoUrl, causeData.sourceRepoUrl)
|
.append(sourceRepoUrl, causeData.sourceRepoUrl)
|
||||||
.append(sourceRepoSshUrl, causeData.sourceRepoSshUrl)
|
.append(sourceRepoSshUrl, causeData.sourceRepoSshUrl)
|
||||||
.append(sourceRepoHttpUrl, causeData.sourceRepoHttpUrl)
|
.append(sourceRepoHttpUrl, causeData.sourceRepoHttpUrl)
|
||||||
.append(mergeRequestTitle, causeData.mergeRequestTitle)
|
.append(pullRequestTitle, causeData.pullRequestTitle)
|
||||||
.append(mergeRequestDescription, causeData.mergeRequestDescription)
|
.append(pullRequestDescription, causeData.pullRequestDescription)
|
||||||
.append(mergeRequestId, causeData.mergeRequestId)
|
.append(pullRequestId, causeData.pullRequestId)
|
||||||
.append(mergeRequestIid, causeData.mergeRequestIid)
|
.append(pullRequestIid, causeData.pullRequestIid)
|
||||||
.append(mergeRequestState, causeData.mergeRequestState)
|
.append(pullRequestState, causeData.pullRequestState)
|
||||||
.append(mergedByUser, causeData.mergedByUser)
|
.append(mergedByUser, causeData.mergedByUser)
|
||||||
.append(mergeRequestAssignee, causeData.mergeRequestAssignee)
|
.append(pullRequestAssignee, causeData.pullRequestAssignee)
|
||||||
.append(mergeRequestTargetProjectId, causeData.mergeRequestTargetProjectId)
|
.append(pullRequestTargetProjectId, causeData.pullRequestTargetProjectId)
|
||||||
.append(targetBranch, causeData.targetBranch)
|
.append(targetBranch, causeData.targetBranch)
|
||||||
.append(targetRepoName, causeData.targetRepoName)
|
.append(targetRepoName, causeData.targetRepoName)
|
||||||
.append(targetNamespace, causeData.targetNamespace)
|
.append(targetNamespace, causeData.targetNamespace)
|
||||||
|
@ -382,14 +384,14 @@ public final class CauseData {
|
||||||
.append(sourceRepoUrl)
|
.append(sourceRepoUrl)
|
||||||
.append(sourceRepoSshUrl)
|
.append(sourceRepoSshUrl)
|
||||||
.append(sourceRepoHttpUrl)
|
.append(sourceRepoHttpUrl)
|
||||||
.append(mergeRequestTitle)
|
.append(pullRequestTitle)
|
||||||
.append(mergeRequestDescription)
|
.append(pullRequestDescription)
|
||||||
.append(mergeRequestId)
|
.append(pullRequestId)
|
||||||
.append(mergeRequestIid)
|
.append(pullRequestIid)
|
||||||
.append(mergeRequestState)
|
.append(pullRequestState)
|
||||||
.append(mergedByUser)
|
.append(mergedByUser)
|
||||||
.append(mergeRequestAssignee)
|
.append(pullRequestAssignee)
|
||||||
.append(mergeRequestTargetProjectId)
|
.append(pullRequestTargetProjectId)
|
||||||
.append(targetBranch)
|
.append(targetBranch)
|
||||||
.append(targetRepoName)
|
.append(targetRepoName)
|
||||||
.append(targetNamespace)
|
.append(targetNamespace)
|
||||||
|
@ -429,14 +431,14 @@ public final class CauseData {
|
||||||
.append("sourceRepoUrl", sourceRepoUrl)
|
.append("sourceRepoUrl", sourceRepoUrl)
|
||||||
.append("sourceRepoSshUrl", sourceRepoSshUrl)
|
.append("sourceRepoSshUrl", sourceRepoSshUrl)
|
||||||
.append("sourceRepoHttpUrl", sourceRepoHttpUrl)
|
.append("sourceRepoHttpUrl", sourceRepoHttpUrl)
|
||||||
.append("mergeRequestTitle", mergeRequestTitle)
|
.append("pullRequestTitle", pullRequestTitle)
|
||||||
.append("mergeRequestDescription", mergeRequestDescription)
|
.append("pullRequestDescription", pullRequestDescription)
|
||||||
.append("mergeRequestId", mergeRequestId)
|
.append("pullRequestId", pullRequestId)
|
||||||
.append("mergeRequestIid", mergeRequestIid)
|
.append("pullRequestIid", pullRequestIid)
|
||||||
.append("mergeRequestState", mergeRequestState)
|
.append("pullRequestState", pullRequestState)
|
||||||
.append("mergedByUser", mergedByUser)
|
.append("mergedByUser", mergedByUser)
|
||||||
.append("mergeRequestAssignee", mergeRequestAssignee)
|
.append("pullRequestAssignee", pullRequestAssignee)
|
||||||
.append("mergeRequestTargetProjectId", mergeRequestTargetProjectId)
|
.append("pullRequestTargetProjectId", pullRequestTargetProjectId)
|
||||||
.append("targetBranch", targetBranch)
|
.append("targetBranch", targetBranch)
|
||||||
.append("targetRepoName", targetRepoName)
|
.append("targetRepoName", targetRepoName)
|
||||||
.append("targetNamespace", targetNamespace)
|
.append("targetNamespace", targetNamespace)
|
||||||
|
@ -476,11 +478,11 @@ public final class CauseData {
|
||||||
String getShortDescription(CauseData data) {
|
String getShortDescription(CauseData data) {
|
||||||
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch()) ? "" : data.getSourceNamespace() + "/";
|
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch()) ? "" : data.getSourceNamespace() + "/";
|
||||||
if (Jenkins.getActiveInstance().getMarkupFormatter() instanceof EscapedMarkupFormatter || data.getTargetProjectUrl() == null) {
|
if (Jenkins.getActiveInstance().getMarkupFormatter() instanceof EscapedMarkupFormatter || data.getTargetProjectUrl() == null) {
|
||||||
return Messages.GiteeWebHookCause_ShortDescription_MergeRequestHook_plain(String.valueOf(data.getMergeRequestIid()),
|
return Messages.GiteeWebHookCause_ShortDescription_PullRequestHook_plain(String.valueOf(data.getPullRequestIid()),
|
||||||
forkNamespace + data.getSourceBranch(),
|
forkNamespace + data.getSourceBranch(),
|
||||||
data.getTargetBranch());
|
data.getTargetBranch());
|
||||||
} else {
|
} else {
|
||||||
return Messages.GiteeWebHookCause_ShortDescription_MergeRequestHook_html(String.valueOf(data.getMergeRequestIid()),
|
return Messages.GiteeWebHookCause_ShortDescription_PullRequestHook_html(String.valueOf(data.getPullRequestIid()),
|
||||||
forkNamespace + data.getSourceBranch(),
|
forkNamespace + data.getSourceBranch(),
|
||||||
data.getTargetBranch(),
|
data.getTargetBranch(),
|
||||||
data.getTargetProjectUrl());
|
data.getTargetProjectUrl());
|
||||||
|
@ -493,12 +495,12 @@ public final class CauseData {
|
||||||
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch()) ? "" : data.getSourceNamespace() + "/";
|
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch()) ? "" : data.getSourceNamespace() + "/";
|
||||||
if (Jenkins.getActiveInstance().getMarkupFormatter() instanceof EscapedMarkupFormatter || data.getTargetProjectUrl() == null) {
|
if (Jenkins.getActiveInstance().getMarkupFormatter() instanceof EscapedMarkupFormatter || data.getTargetProjectUrl() == null) {
|
||||||
return Messages.GiteeWebHookCause_ShortDescription_NoteHook_plain(triggeredBy,
|
return Messages.GiteeWebHookCause_ShortDescription_NoteHook_plain(triggeredBy,
|
||||||
String.valueOf(data.getMergeRequestIid()),
|
String.valueOf(data.getPullRequestIid()),
|
||||||
forkNamespace + data.getSourceBranch(),
|
forkNamespace + data.getSourceBranch(),
|
||||||
data.getTargetBranch());
|
data.getTargetBranch());
|
||||||
} else {
|
} else {
|
||||||
return Messages.GiteeWebHookCause_ShortDescription_NoteHook_html(triggeredBy,
|
return Messages.GiteeWebHookCause_ShortDescription_NoteHook_html(triggeredBy,
|
||||||
String.valueOf(data.getMergeRequestIid()),
|
String.valueOf(data.getPullRequestIid()),
|
||||||
forkNamespace + data.getSourceBranch(),
|
forkNamespace + data.getSourceBranch(),
|
||||||
data.getTargetBranch(),
|
data.getTargetBranch(),
|
||||||
data.getTargetProjectUrl());
|
data.getTargetProjectUrl());
|
||||||
|
|
|
@ -47,6 +47,15 @@ public class GiteeConnectionProperty extends JobProperty<Job<?, ?>> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GiteeClient getClient(Job<?, ?> job) {
|
||||||
|
final GiteeConnectionProperty connectionProperty = job.getProperty(GiteeConnectionProperty.class);
|
||||||
|
if (connectionProperty != null) {
|
||||||
|
return connectionProperty.getClient();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@Symbol("giteeConnection")
|
@Symbol("giteeConnection")
|
||||||
public static class DescriptorImpl extends JobPropertyDescriptor {
|
public static class DescriptorImpl extends JobPropertyDescriptor {
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.gitee.jenkins.gitee.api.model.*;
|
||||||
public interface GiteeClient {
|
public interface GiteeClient {
|
||||||
String getHostUrl();
|
String getHostUrl();
|
||||||
|
|
||||||
void acceptMergeRequest(MergeRequest mr, String mergeCommitMessage, boolean shouldRemoveSourceBranch);
|
void acceptPullRequest(PullRequest mr, String mergeCommitMessage, boolean shouldRemoveSourceBranch);
|
||||||
|
|
||||||
void createMergeRequestNote(MergeRequest mr, String body);
|
void createPullRequestNote(PullRequest mr, String body);
|
||||||
|
|
||||||
User getCurrentUser();
|
User getCurrentUser();
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import com.gitee.jenkins.gitee.api.model.*;
|
||||||
|
|
||||||
|
|
||||||
interface GiteeApiProxy {
|
interface GiteeApiProxy {
|
||||||
void createMergeRequestNote(String owner, String repo, Integer mergeRequestId, String body);
|
void createPullRequestNote(String owner, String repo, Integer pullRequestId, String body);
|
||||||
void headCurrentUser();
|
void headCurrentUser();
|
||||||
void acceptMergeRequest(String owner, String repo, Integer mergeRequestId);
|
void acceptPullRequest(String owner, String repo, Integer pullRequestId);
|
||||||
User getCurrentUser();
|
User getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ interface GiteeV5ApiProxy extends GiteeApiProxy {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
@Path("/repos/{ownerPath}/{repoPath}/pulls/{prNumber}/merge")
|
@Path("/repos/{ownerPath}/{repoPath}/pulls/{prNumber}/merge")
|
||||||
void acceptMergeRequest(@PathParam("ownerPath") String ownerPath,
|
void acceptPullRequest(@PathParam("ownerPath") String ownerPath,
|
||||||
@PathParam("repoPath") String repoPath,
|
@PathParam("repoPath") String repoPath,
|
||||||
@PathParam("prNumber") Integer prNumber);
|
@PathParam("prNumber") Integer prNumber);
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ interface GiteeV5ApiProxy extends GiteeApiProxy {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
@Path("/repos/{ownerPath}/{repoPath}/pulls/{prNumber}/comments")
|
@Path("/repos/{ownerPath}/{repoPath}/pulls/{prNumber}/comments")
|
||||||
void createMergeRequestNote(@PathParam("ownerPath") String ownerPath,
|
void createPullRequestNote(@PathParam("ownerPath") String ownerPath,
|
||||||
@PathParam("repoPath") String repoPath,
|
@PathParam("repoPath") String repoPath,
|
||||||
@PathParam("prNumber") Integer prNumber,
|
@PathParam("prNumber") Integer prNumber,
|
||||||
@FormParam("body") String body);
|
@FormParam("body") String body);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.gitee.jenkins.gitee.api.impl;
|
package com.gitee.jenkins.gitee.api.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import hudson.Extension;
|
import hudson.Extension;
|
||||||
import org.kohsuke.accmod.Restricted;
|
import org.kohsuke.accmod.Restricted;
|
||||||
|
@ -12,10 +12,10 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||||
@Restricted(NoExternalUse.class)
|
@Restricted(NoExternalUse.class)
|
||||||
public final class GiteeV5ClientBuilder extends ResteasyGiteeClientBuilder {
|
public final class GiteeV5ClientBuilder extends ResteasyGiteeClientBuilder {
|
||||||
private static final int ORDINAL = 3;
|
private static final int ORDINAL = 3;
|
||||||
private static final Function<MergeRequest, Integer> MERGE_REQUEST_ID_PROVIDER = new Function<MergeRequest, Integer>() {
|
private static final Function<PullRequest, Integer> MERGE_REQUEST_ID_PROVIDER = new Function<PullRequest, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer apply(MergeRequest mergeRequest) {
|
public Integer apply(PullRequest pullRequest) {
|
||||||
return mergeRequest.getIid();
|
return pullRequest.getIid();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,13 @@ import com.google.common.base.Function;
|
||||||
final class ResteasyGiteeClient implements GiteeClient {
|
final class ResteasyGiteeClient implements GiteeClient {
|
||||||
private final String hostUrl;
|
private final String hostUrl;
|
||||||
private final GiteeApiProxy api;
|
private final GiteeApiProxy api;
|
||||||
private final Function<MergeRequest, Integer> mergeRequestIdProvider;
|
private final Function<PullRequest, Integer> pullRequestIdProvider;
|
||||||
|
|
||||||
ResteasyGiteeClient(String hostUrl, GiteeApiProxy api, Function<MergeRequest, Integer> mergeRequestIdProvider) {
|
|
||||||
|
ResteasyGiteeClient(String hostUrl, GiteeApiProxy api, Function<PullRequest, Integer> pullRequestIdProvider) {
|
||||||
this.hostUrl = hostUrl;
|
this.hostUrl = hostUrl;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.mergeRequestIdProvider = mergeRequestIdProvider;
|
this.pullRequestIdProvider = pullRequestIdProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,13 +25,13 @@ final class ResteasyGiteeClient implements GiteeClient {
|
||||||
|
|
||||||
// Gitee v5 don't support commit message and remove source branch
|
// Gitee v5 don't support commit message and remove source branch
|
||||||
@Override
|
@Override
|
||||||
public void acceptMergeRequest(MergeRequest mr, String mergeCommitMessage, boolean shouldRemoveSourceBranch) {
|
public void acceptPullRequest(PullRequest mr, String mergeCommitMessage, boolean shouldRemoveSourceBranch) {
|
||||||
api.acceptMergeRequest(mr.getRepoOwner(), mr.getRepoPath(), mergeRequestIdProvider.apply(mr));
|
api.acceptPullRequest(mr.getRepoOwner(), mr.getRepoPath(), mr.getIid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMergeRequestNote(MergeRequest mr, String body) {
|
public void createPullRequestNote(PullRequest mr, String body) {
|
||||||
api.createMergeRequestNote(mr.getRepoOwner(), mr.getRepoPath(), mergeRequestIdProvider.apply(mr), body);
|
api.createPullRequestNote(mr.getRepoOwner(), mr.getRepoPath(), mr.getIid(), body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,7 +4,7 @@ package com.gitee.jenkins.gitee.api.impl;
|
||||||
import com.gitee.jenkins.gitee.JacksonConfig;
|
import com.gitee.jenkins.gitee.JacksonConfig;
|
||||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||||
import com.gitee.jenkins.gitee.api.GiteeClientBuilder;
|
import com.gitee.jenkins.gitee.api.GiteeClientBuilder;
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import com.gitee.jenkins.util.JsonUtil;
|
import com.gitee.jenkins.util.JsonUtil;
|
||||||
import com.gitee.jenkins.util.LoggerUtil;
|
import com.gitee.jenkins.util.LoggerUtil;
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||||
|
@ -67,12 +67,12 @@ public class ResteasyGiteeClientBuilder extends GiteeClientBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Class<? extends GiteeApiProxy> apiProxyClass;
|
private final Class<? extends GiteeApiProxy> apiProxyClass;
|
||||||
private final Function<MergeRequest, Integer> mergeRequestIdProvider;
|
private final Function<PullRequest, Integer> pullRequestIdProvider;
|
||||||
|
|
||||||
ResteasyGiteeClientBuilder(String id, int ordinal, Class<? extends GiteeApiProxy> apiProxyClass, Function<MergeRequest, Integer> mergeRequestIdProvider) {
|
ResteasyGiteeClientBuilder(String id, int ordinal, Class<? extends GiteeApiProxy> apiProxyClass, Function<PullRequest, Integer> pullRequestIdProvider) {
|
||||||
super(id, ordinal);
|
super(id, ordinal);
|
||||||
this.apiProxyClass = apiProxyClass;
|
this.apiProxyClass = apiProxyClass;
|
||||||
this.mergeRequestIdProvider = mergeRequestIdProvider;
|
this.pullRequestIdProvider = pullRequestIdProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -124,7 +124,7 @@ public class ResteasyGiteeClientBuilder extends GiteeClientBuilder {
|
||||||
.classloader(apiProxyClass.getClassLoader())
|
.classloader(apiProxyClass.getClassLoader())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return new ResteasyGiteeClient(url, apiProxy, mergeRequestIdProvider);
|
return new ResteasyGiteeClient(url, apiProxy, pullRequestIdProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHost(String url) {
|
private String getHost(String url) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class Label {
|
||||||
private String description;
|
private String description;
|
||||||
private long openIssuesCount;
|
private long openIssuesCount;
|
||||||
private long closedIssuesCount;
|
private long closedIssuesCount;
|
||||||
private long openMergeRequestsCount;
|
private long openPullRequestsCount;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -65,12 +65,12 @@ public class Label {
|
||||||
this.closedIssuesCount = closedIssuesCount;
|
this.closedIssuesCount = closedIssuesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getOpenMergeRequestsCount() {
|
public long getOpenPullRequestsCount() {
|
||||||
return openMergeRequestsCount;
|
return openPullRequestsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOpenMergeRequestsCount(long openMergeRequestsCount) {
|
public void setOpenPullRequestsCount(long openPullRequestsCount) {
|
||||||
this.openMergeRequestsCount = openMergeRequestsCount;
|
this.openPullRequestsCount = openPullRequestsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,7 +85,7 @@ public class Label {
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(openIssuesCount, label.openIssuesCount)
|
.append(openIssuesCount, label.openIssuesCount)
|
||||||
.append(closedIssuesCount, label.closedIssuesCount)
|
.append(closedIssuesCount, label.closedIssuesCount)
|
||||||
.append(openMergeRequestsCount, label.openMergeRequestsCount)
|
.append(openPullRequestsCount, label.openPullRequestsCount)
|
||||||
.append(name, label.name)
|
.append(name, label.name)
|
||||||
.append(color, label.color)
|
.append(color, label.color)
|
||||||
.append(description, label.description)
|
.append(description, label.description)
|
||||||
|
@ -100,7 +100,7 @@ public class Label {
|
||||||
.append(description)
|
.append(description)
|
||||||
.append(openIssuesCount)
|
.append(openIssuesCount)
|
||||||
.append(closedIssuesCount)
|
.append(closedIssuesCount)
|
||||||
.append(openMergeRequestsCount)
|
.append(openPullRequestsCount)
|
||||||
.toHashCode();
|
.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class Label {
|
||||||
.append("description", description)
|
.append("description", description)
|
||||||
.append("openIssuesCount", openIssuesCount)
|
.append("openIssuesCount", openIssuesCount)
|
||||||
.append("closedIssuesCount", closedIssuesCount)
|
.append("closedIssuesCount", closedIssuesCount)
|
||||||
.append("openMergeRequestsCount", openMergeRequestsCount)
|
.append("openPullRequestsCount", openPullRequestsCount)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.gitee.jenkins.gitee.api.model;
|
package com.gitee.jenkins.gitee.api.model;
|
||||||
|
|
||||||
|
import com.gitee.jenkins.gitee.hook.model.PullRequestObjectAttributes;
|
||||||
import com.gitee.jenkins.gitee.hook.model.State;
|
import com.gitee.jenkins.gitee.hook.model.State;
|
||||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||||
|
@ -12,7 +13,7 @@ import java.util.List;
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||||
public class MergeRequest {
|
public class PullRequest {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private Integer iid;
|
private Integer iid;
|
||||||
private String sourceBranch;
|
private String sourceBranch;
|
||||||
|
@ -34,11 +35,11 @@ public class MergeRequest {
|
||||||
private String repoOwner;
|
private String repoOwner;
|
||||||
private String repoPath;
|
private String repoPath;
|
||||||
|
|
||||||
public MergeRequest() { /* default-constructor for Resteasy-based-api-proxies */ }
|
public PullRequest() { /* default-constructor for Resteasy-based-api-proxies */ }
|
||||||
|
|
||||||
public MergeRequest(int id, int iid, String sourceBranch, String targetBranch, String title,
|
public PullRequest(int id, int iid, String sourceBranch, String targetBranch, String title,
|
||||||
int sourceProjectId, int targetProjectId,
|
int sourceProjectId, int targetProjectId,
|
||||||
String description, String mergeStatus) {
|
String description, String mergeStatus) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.iid= iid;
|
this.iid= iid;
|
||||||
this.sourceBranch = sourceBranch;
|
this.sourceBranch = sourceBranch;
|
||||||
|
@ -50,9 +51,29 @@ public class MergeRequest {
|
||||||
this.mergeStatus = mergeStatus;
|
this.mergeStatus = mergeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MergeRequest(int id, int iid, String sourceBranch, String targetBranch, String title,
|
public PullRequest(PullRequestObjectAttributes objectAttributes) {
|
||||||
int sourceProjectId, int targetProjectId,
|
this.id = objectAttributes.getId();
|
||||||
String description, String mergeStatus, String pathWithNamespace) {
|
this.iid= objectAttributes.getNumber();
|
||||||
|
this.sourceBranch = objectAttributes.getSourceBranch();
|
||||||
|
this.targetBranch = objectAttributes.getTargetBranch();
|
||||||
|
this.title = objectAttributes.getTitle();
|
||||||
|
this.sourceProjectId = objectAttributes.getSourceProjectId();
|
||||||
|
this.projectId = objectAttributes.getTargetProjectId();
|
||||||
|
this.description = objectAttributes.getBody();
|
||||||
|
this.mergeStatus = objectAttributes.getMergeStatus();
|
||||||
|
|
||||||
|
// try {
|
||||||
|
String[] path = objectAttributes.getTarget().getPathWithNamespace().split("/");
|
||||||
|
this.repoOwner = path[0];
|
||||||
|
this.repoPath = path[1];
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// // do nothing
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public PullRequest(int id, int iid, String sourceBranch, String targetBranch, String title,
|
||||||
|
int sourceProjectId, int targetProjectId,
|
||||||
|
String description, String mergeStatus, String pathWithNamespace) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.iid= iid;
|
this.iid= iid;
|
||||||
this.sourceBranch = sourceBranch;
|
this.sourceBranch = sourceBranch;
|
||||||
|
@ -64,10 +85,8 @@ public class MergeRequest {
|
||||||
this.mergeStatus = mergeStatus;
|
this.mergeStatus = mergeStatus;
|
||||||
try {
|
try {
|
||||||
String[] path = pathWithNamespace.split("/");
|
String[] path = pathWithNamespace.split("/");
|
||||||
String repoOwner = path[0];
|
this.repoOwner = path[0];
|
||||||
String repoPath = path[1];
|
this.repoPath = path[1];
|
||||||
this.repoOwner = repoOwner;
|
|
||||||
this.repoPath = repoPath;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -241,7 +260,7 @@ public class MergeRequest {
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MergeRequest that = (MergeRequest) o;
|
PullRequest that = (PullRequest) o;
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(id, that.id)
|
.append(id, that.id)
|
||||||
.append(iid, that.iid)
|
.append(iid, that.iid)
|
|
@ -14,7 +14,7 @@ public class NoteHook extends WebHook {
|
||||||
|
|
||||||
private User user;
|
private User user;
|
||||||
private Project project;
|
private Project project;
|
||||||
private MergeRequestObjectAttributes mergeRequest;
|
private PullRequestObjectAttributes pullRequest;
|
||||||
private NoteObjectAttributes objectAttributes;
|
private NoteObjectAttributes objectAttributes;
|
||||||
|
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
|
@ -41,12 +41,12 @@ public class NoteHook extends WebHook {
|
||||||
this.objectAttributes = objectAttributes;
|
this.objectAttributes = objectAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MergeRequestObjectAttributes getMergeRequest() {
|
public PullRequestObjectAttributes getPullRequest() {
|
||||||
return mergeRequest;
|
return pullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMergeRequest(MergeRequestObjectAttributes mergeRequest) {
|
public void setPullRequest(PullRequestObjectAttributes pullRequest) {
|
||||||
this.mergeRequest = mergeRequest;
|
this.pullRequest = pullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +62,7 @@ public class NoteHook extends WebHook {
|
||||||
.append(user, that.user)
|
.append(user, that.user)
|
||||||
.append(project, that.project)
|
.append(project, that.project)
|
||||||
.append(objectAttributes, that.objectAttributes)
|
.append(objectAttributes, that.objectAttributes)
|
||||||
.append(mergeRequest, that.mergeRequest)
|
.append(pullRequest, that.pullRequest)
|
||||||
.isEquals();
|
.isEquals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class NoteHook extends WebHook {
|
||||||
.append(user)
|
.append(user)
|
||||||
.append(project)
|
.append(project)
|
||||||
.append(objectAttributes)
|
.append(objectAttributes)
|
||||||
.append(mergeRequest)
|
.append(pullRequest)
|
||||||
.toHashCode();
|
.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class NoteHook extends WebHook {
|
||||||
.append("user", user)
|
.append("user", user)
|
||||||
.append("project", project)
|
.append("project", project)
|
||||||
.append("objectAttributes", objectAttributes)
|
.append("objectAttributes", objectAttributes)
|
||||||
.append("mergeRequest", mergeRequest)
|
.append("pullRequest", pullRequest)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,15 @@ import java.util.List;
|
||||||
* @author Yashin Luo
|
* @author Yashin Luo
|
||||||
*/
|
*/
|
||||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||||
public class MergeRequestHook extends WebHook {
|
public class PullRequestHook extends WebHook {
|
||||||
|
|
||||||
private User user;
|
private User user;
|
||||||
private User assignee;
|
private User assignee;
|
||||||
private Project repo;
|
private Project repo;
|
||||||
private Action action;
|
private Action action;
|
||||||
private State state;
|
private State state;
|
||||||
private MergeRequestObjectAttributes pullRequest;
|
private PullRequestObjectAttributes pullRequest;
|
||||||
private List<MergeRequestLabel> labels;
|
private List<PullRequestLabel> labels;
|
||||||
|
|
||||||
public Action getAction() {
|
public Action getAction() {
|
||||||
return action;
|
return action;
|
||||||
|
@ -63,19 +63,19 @@ public class MergeRequestHook extends WebHook {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MergeRequestObjectAttributes getPullRequest() {
|
public PullRequestObjectAttributes getPullRequest() {
|
||||||
return pullRequest;
|
return pullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPullRequest(MergeRequestObjectAttributes pullRequest) {
|
public void setPullRequest(PullRequestObjectAttributes pullRequest) {
|
||||||
this.pullRequest = pullRequest;
|
this.pullRequest = pullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MergeRequestLabel> getLabels() {
|
public List<PullRequestLabel> getLabels() {
|
||||||
return labels;
|
return labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabels(List<MergeRequestLabel> labels) {
|
public void setLabels(List<PullRequestLabel> labels) {
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class MergeRequestHook extends WebHook {
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MergeRequestHook that = (MergeRequestHook) o;
|
PullRequestHook that = (PullRequestHook) o;
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(user, that.user)
|
.append(user, that.user)
|
||||||
.append(assignee, that.assignee)
|
.append(assignee, that.assignee)
|
|
@ -11,7 +11,7 @@ import java.util.Date;
|
||||||
* @author Benjamin ROBIN
|
* @author Benjamin ROBIN
|
||||||
*/
|
*/
|
||||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||||
public class MergeRequestLabel {
|
public class PullRequestLabel {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
"id": 206,
|
"id": 206,
|
||||||
|
@ -124,7 +124,7 @@ public class MergeRequestLabel {
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MergeRequestLabel that = (MergeRequestLabel) o;
|
PullRequestLabel that = (PullRequestLabel) o;
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(id, that.id)
|
.append(id, that.id)
|
||||||
.append(title, that.title)
|
.append(title, that.title)
|
|
@ -1,6 +1,7 @@
|
||||||
package com.gitee.jenkins.gitee.hook.model;
|
package com.gitee.jenkins.gitee.hook.model;
|
||||||
|
|
||||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||||
|
@ -12,8 +13,11 @@ import java.util.Date;
|
||||||
* @author Yashin
|
* @author Yashin
|
||||||
*/
|
*/
|
||||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||||
public class MergeRequestObjectAttributes {
|
public class PullRequestObjectAttributes {
|
||||||
|
|
||||||
|
private final static String UNCHECKED = "unchecked";
|
||||||
|
private final static String CAN_BE_MERGED = "can_be_merged";
|
||||||
|
private final static String CANNOT_BE_MERGED = "cannot_be_merged";
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private Integer number;
|
private Integer number;
|
||||||
private Integer authorId;
|
private Integer authorId;
|
||||||
|
@ -175,6 +179,10 @@ public class MergeRequestObjectAttributes {
|
||||||
this.workInProgress = workInProgress;
|
this.workInProgress = workInProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean can_be_merged() {
|
||||||
|
return StringUtils.isNotBlank(mergeCommitSha) && !StringUtils.equals(CANNOT_BE_MERGED, mergeStatus);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
|
@ -183,7 +191,7 @@ public class MergeRequestObjectAttributes {
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MergeRequestObjectAttributes that = (MergeRequestObjectAttributes) o;
|
PullRequestObjectAttributes that = (PullRequestObjectAttributes) o;
|
||||||
return new EqualsBuilder()
|
return new EqualsBuilder()
|
||||||
.append(id, that.id)
|
.append(id, that.id)
|
||||||
.append(number, that.number)
|
.append(number, that.number)
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.publisher;
|
||||||
|
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import hudson.Extension;
|
import hudson.Extension;
|
||||||
import hudson.model.AbstractProject;
|
import hudson.model.AbstractProject;
|
||||||
import hudson.model.Result;
|
import hudson.model.Result;
|
||||||
|
@ -21,11 +21,11 @@ import java.util.logging.Logger;
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
public class GiteeAcceptMergeRequestPublisher extends MergeRequestNotifier {
|
public class GiteeAcceptPullRequestPublisher extends PullRequestNotifier {
|
||||||
private static final Logger LOGGER = Logger.getLogger(GiteeAcceptMergeRequestPublisher.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(GiteeAcceptPullRequestPublisher.class.getName());
|
||||||
|
|
||||||
@DataBoundConstructor
|
@DataBoundConstructor
|
||||||
public GiteeAcceptMergeRequestPublisher() { }
|
public GiteeAcceptPullRequestPublisher() { }
|
||||||
|
|
||||||
public BuildStepMonitor getRequiredMonitorService() {
|
public BuildStepMonitor getRequiredMonitorService() {
|
||||||
return BuildStepMonitor.NONE;
|
return BuildStepMonitor.NONE;
|
||||||
|
@ -41,19 +41,19 @@ public class GiteeAcceptMergeRequestPublisher extends MergeRequestNotifier {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return Messages.GiteeAcceptMergeRequestPublisher_DisplayName();
|
return Messages.GiteeAcceptPullRequestPublisher_DisplayName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest) {
|
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, PullRequest pullRequest) {
|
||||||
try {
|
try {
|
||||||
if (build.getResult() == Result.SUCCESS) {
|
if (build.getResult() == Result.SUCCESS) {
|
||||||
client.acceptMergeRequest(mergeRequest, "Merge Request accepted by jenkins build success", false);
|
client.acceptPullRequest(pullRequest, "Merge Request accepted by jenkins build success", false);
|
||||||
}
|
}
|
||||||
} catch (WebApplicationException | ProcessingException e) {
|
} catch (WebApplicationException | ProcessingException e) {
|
||||||
listener.getLogger().printf("Failed to accept merge request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
listener.getLogger().printf("Failed to accept pull request for project '%s': %s%n", pullRequest.getProjectId(), e.getMessage());
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to accept merge request for project '%s'", mergeRequest.getProjectId()), e);
|
LOGGER.log(Level.SEVERE, String.format("Failed to accept pull request for project '%s'", pullRequest.getProjectId()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,16 +2,17 @@ package com.gitee.jenkins.publisher;
|
||||||
|
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
|
import com.gitee.jenkins.trigger.GiteePushTrigger;
|
||||||
import hudson.Extension;
|
import hudson.Extension;
|
||||||
import hudson.Util;
|
import hudson.Util;
|
||||||
import hudson.model.AbstractProject;
|
import hudson.model.*;
|
||||||
import hudson.model.Result;
|
|
||||||
import hudson.model.Run;
|
|
||||||
import hudson.model.TaskListener;
|
|
||||||
import hudson.tasks.BuildStepDescriptor;
|
import hudson.tasks.BuildStepDescriptor;
|
||||||
|
import hudson.tasks.Notifier;
|
||||||
import hudson.tasks.Publisher;
|
import hudson.tasks.Publisher;
|
||||||
|
import hudson.triggers.Trigger;
|
||||||
import jenkins.model.Jenkins;
|
import jenkins.model.Jenkins;
|
||||||
|
import jenkins.model.ParameterizedJobMixIn;
|
||||||
import org.kohsuke.stapler.DataBoundConstructor;
|
import org.kohsuke.stapler.DataBoundConstructor;
|
||||||
import org.kohsuke.stapler.DataBoundSetter;
|
import org.kohsuke.stapler.DataBoundSetter;
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ import java.util.logging.Logger;
|
||||||
/**
|
/**
|
||||||
* @author Nikolay Ustinov
|
* @author Nikolay Ustinov
|
||||||
*/
|
*/
|
||||||
public class GiteeMessagePublisher extends MergeRequestNotifier {
|
public class GiteeMessagePublisher extends PullRequestNotifier {
|
||||||
private static final Logger LOGGER = Logger.getLogger(GiteeMessagePublisher.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(GiteeMessagePublisher.class.getName());
|
||||||
private boolean onlyForFailure = false;
|
private boolean onlyForFailure = false;
|
||||||
private boolean replaceSuccessNote = false;
|
private boolean replaceSuccessNote = false;
|
||||||
|
@ -58,6 +59,20 @@ public class GiteeMessagePublisher extends MergeRequestNotifier {
|
||||||
@DataBoundConstructor
|
@DataBoundConstructor
|
||||||
public GiteeMessagePublisher() { }
|
public GiteeMessagePublisher() { }
|
||||||
|
|
||||||
|
public static GiteeMessagePublisher getFromJob(Job<?, ?> job) {
|
||||||
|
GiteeMessagePublisher publisher = null;
|
||||||
|
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
|
||||||
|
AbstractProject p = (AbstractProject) job;
|
||||||
|
Map<Descriptor<Publisher>, Publisher> map = p.getPublishersList().toMap();
|
||||||
|
for (Publisher n : map.values()) {
|
||||||
|
if (n instanceof GiteeMessagePublisher) {
|
||||||
|
publisher = (GiteeMessagePublisher) n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return publisher;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOnlyForFailure() {
|
public boolean isOnlyForFailure() {
|
||||||
return onlyForFailure;
|
return onlyForFailure;
|
||||||
}
|
}
|
||||||
|
@ -159,14 +174,14 @@ public class GiteeMessagePublisher extends MergeRequestNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest) {
|
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, PullRequest pullRequest) {
|
||||||
try {
|
try {
|
||||||
if (!onlyForFailure || build.getResult() == Result.FAILURE || build.getResult() == Result.UNSTABLE) {
|
if (!onlyForFailure || build.getResult() == Result.FAILURE || build.getResult() == Result.UNSTABLE) {
|
||||||
client.createMergeRequestNote(mergeRequest, getNote(build, listener));
|
client.createPullRequestNote(pullRequest, getNote(build, listener));
|
||||||
}
|
}
|
||||||
} catch (WebApplicationException | ProcessingException e) {
|
} catch (WebApplicationException | ProcessingException e) {
|
||||||
listener.getLogger().printf("Failed to add comment on Merge Request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
listener.getLogger().printf("Failed to add comment on Merge Request for project '%s': %s%n", pullRequest.getProjectId(), e.getMessage());
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to add comment on Merge Request for project '%s'", mergeRequest.getProjectId()), e);
|
LOGGER.log(Level.SEVERE, String.format("Failed to add comment on Merge Request for project '%s'", pullRequest.getProjectId()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.publisher;
|
||||||
|
|
||||||
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
||||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import hudson.Launcher;
|
import hudson.Launcher;
|
||||||
import hudson.matrix.MatrixAggregatable;
|
import hudson.matrix.MatrixAggregatable;
|
||||||
import hudson.matrix.MatrixAggregator;
|
import hudson.matrix.MatrixAggregator;
|
||||||
|
@ -21,7 +21,7 @@ import static com.gitee.jenkins.connection.GiteeConnectionProperty.getClient;
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
public abstract class MergeRequestNotifier extends Notifier implements MatrixAggregatable {
|
public abstract class PullRequestNotifier extends Notifier implements MatrixAggregatable {
|
||||||
public BuildStepMonitor getRequiredMonitorService() {
|
public BuildStepMonitor getRequiredMonitorService() {
|
||||||
return BuildStepMonitor.NONE;
|
return BuildStepMonitor.NONE;
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ public abstract class MergeRequestNotifier extends Notifier implements MatrixAgg
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeRequest mergeRequest = getMergeRequest(build);
|
PullRequest pullRequest = getPullRequest(build);
|
||||||
if (mergeRequest != null) {
|
if (pullRequest != null) {
|
||||||
perform(build, listener, client, mergeRequest);
|
perform(build, listener, client, pullRequest);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,11 @@ public abstract class MergeRequestNotifier extends Notifier implements MatrixAgg
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest);
|
protected abstract void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, PullRequest pullRequest);
|
||||||
|
|
||||||
MergeRequest getMergeRequest(Run<?, ?> run) {
|
PullRequest getPullRequest(Run<?, ?> run) {
|
||||||
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
||||||
return cause == null ? null : cause.getData().getMergeRequest();
|
return cause == null ? null : cause.getData().getPullRequest();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,19 +4,15 @@ package com.gitee.jenkins.trigger;
|
||||||
import com.gitee.jenkins.connection.GiteeConnection;
|
import com.gitee.jenkins.connection.GiteeConnection;
|
||||||
import com.gitee.jenkins.connection.GiteeConnectionConfig;
|
import com.gitee.jenkins.connection.GiteeConnectionConfig;
|
||||||
import com.gitee.jenkins.connection.GiteeConnectionProperty;
|
import com.gitee.jenkins.connection.GiteeConnectionProperty;
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestHook;
|
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||||
import com.gitee.jenkins.gitee.hook.model.NoteHook;
|
import com.gitee.jenkins.gitee.hook.model.NoteHook;
|
||||||
import com.gitee.jenkins.gitee.hook.model.PipelineHook;
|
import com.gitee.jenkins.gitee.hook.model.PipelineHook;
|
||||||
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
||||||
import com.gitee.jenkins.publisher.GiteeAcceptMergeRequestPublisher;
|
import com.gitee.jenkins.publisher.GiteeAcceptPullRequestPublisher;
|
||||||
import com.gitee.jenkins.publisher.GiteeMessagePublisher;
|
import com.gitee.jenkins.publisher.GiteeMessagePublisher;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.*;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilterFactory;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilterConfig;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilterType;
|
import com.gitee.jenkins.trigger.handler.merge.PullRequestHookTriggerHandler;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilterConfig;
|
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilterFactory;
|
|
||||||
import com.gitee.jenkins.trigger.handler.merge.MergeRequestHookTriggerHandler;
|
|
||||||
import com.gitee.jenkins.trigger.handler.note.NoteHookTriggerHandler;
|
import com.gitee.jenkins.trigger.handler.note.NoteHookTriggerHandler;
|
||||||
import com.gitee.jenkins.trigger.handler.pipeline.PipelineHookTriggerHandler;
|
import com.gitee.jenkins.trigger.handler.pipeline.PipelineHookTriggerHandler;
|
||||||
import com.gitee.jenkins.trigger.handler.push.PushHookTriggerHandler;
|
import com.gitee.jenkins.trigger.handler.push.PushHookTriggerHandler;
|
||||||
|
@ -51,7 +47,7 @@ import java.io.ObjectStreamException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
import static com.gitee.jenkins.trigger.filter.BranchFilterConfig.BranchFilterConfigBuilder.branchFilterConfig;
|
import static com.gitee.jenkins.trigger.filter.BranchFilterConfig.BranchFilterConfigBuilder.branchFilterConfig;
|
||||||
import static com.gitee.jenkins.trigger.handler.merge.MergeRequestHookTriggerHandlerFactory.newMergeRequestHookTriggerHandler;
|
import static com.gitee.jenkins.trigger.handler.merge.PullRequestHookTriggerHandlerFactory.newPullRequestHookTriggerHandler;
|
||||||
import static com.gitee.jenkins.trigger.handler.note.NoteHookTriggerHandlerFactory.newNoteHookTriggerHandler;
|
import static com.gitee.jenkins.trigger.handler.note.NoteHookTriggerHandlerFactory.newNoteHookTriggerHandler;
|
||||||
import static com.gitee.jenkins.trigger.handler.pipeline.PipelineHookTriggerHandlerFactory.newPipelineHookTriggerHandler;
|
import static com.gitee.jenkins.trigger.handler.pipeline.PipelineHookTriggerHandlerFactory.newPipelineHookTriggerHandler;
|
||||||
import static com.gitee.jenkins.trigger.handler.push.PushHookTriggerHandlerFactory.newPushHookTriggerHandler;
|
import static com.gitee.jenkins.trigger.handler.push.PushHookTriggerHandlerFactory.newPushHookTriggerHandler;
|
||||||
|
@ -69,82 +65,82 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
private static final SecureRandom RANDOM = new SecureRandom();
|
private static final SecureRandom RANDOM = new SecureRandom();
|
||||||
|
|
||||||
private boolean triggerOnPush = true;
|
private boolean triggerOnPush = true;
|
||||||
private boolean triggerOnOpenMergeRequest = true;
|
private boolean triggerOnOpenPullRequest = true;
|
||||||
private boolean triggerOnPipelineEvent = false;
|
private boolean triggerOnPipelineEvent = false;
|
||||||
private boolean triggerOnAcceptedMergeRequest = false;
|
private boolean triggerOnAcceptedPullRequest = false;
|
||||||
private boolean triggerOnUpdateMergeRequest = false;
|
private boolean triggerOnUpdatePullRequest = false;
|
||||||
private boolean triggerOnClosedMergeRequest = false;
|
private boolean triggerOnClosedPullRequest = false;
|
||||||
private boolean triggerOnApprovedMergeRequest = false;
|
private boolean triggerOnApprovedPullRequest = false;
|
||||||
private boolean triggerOnTestedMergeRequest = false;
|
private boolean triggerOnTestedPullRequest = false;
|
||||||
private boolean triggerOnNoteRequest = true;
|
private boolean triggerOnNoteRequest = true;
|
||||||
private String noteRegex = "";
|
private String noteRegex = "";
|
||||||
private boolean ciSkip = true;
|
private boolean ciSkip = true;
|
||||||
private boolean skipWorkInProgressMergeRequest;
|
private boolean skipWorkInProgressPullRequest;
|
||||||
private boolean skipLastCommitHasBeenBuild;
|
private boolean skipLastCommitHasBeenBuild;
|
||||||
private boolean setBuildDescription = true;
|
private boolean setBuildDescription = true;
|
||||||
private transient boolean addNoteOnMergeRequest;
|
private transient boolean addNoteOnPullRequest;
|
||||||
private transient boolean addCiMessage;
|
private transient boolean addCiMessage;
|
||||||
private transient boolean addVoteOnMergeRequest;
|
private transient boolean addVoteOnPullRequest;
|
||||||
private transient boolean allowAllBranches = false;
|
private transient boolean allowAllBranches = false;
|
||||||
private transient String branchFilterName;
|
private transient String branchFilterName;
|
||||||
private BranchFilterType branchFilterType;
|
private BranchFilterType branchFilterType;
|
||||||
private String includeBranchesSpec;
|
private String includeBranchesSpec;
|
||||||
private String excludeBranchesSpec;
|
private String excludeBranchesSpec;
|
||||||
private String targetBranchRegex;
|
private String targetBranchRegex;
|
||||||
private MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig;
|
private PullRequestLabelFilterConfig pullRequestLabelFilterConfig;
|
||||||
private volatile Secret secretToken;
|
private volatile Secret secretToken;
|
||||||
private String pendingBuildName;
|
private String pendingBuildName;
|
||||||
private boolean cancelPendingBuildsOnUpdate;
|
private boolean cancelPendingBuildsOnUpdate;
|
||||||
|
|
||||||
private transient BranchFilter branchFilter;
|
private transient BranchFilter branchFilter;
|
||||||
private transient PushHookTriggerHandler pushHookTriggerHandler;
|
private transient PushHookTriggerHandler pushHookTriggerHandler;
|
||||||
private transient MergeRequestHookTriggerHandler mergeRequestHookTriggerHandler;
|
private transient PullRequestHookTriggerHandler pullRequestHookTriggerHandler;
|
||||||
private transient NoteHookTriggerHandler noteHookTriggerHandler;
|
private transient NoteHookTriggerHandler noteHookTriggerHandler;
|
||||||
private transient PipelineHookTriggerHandler pipelineTriggerHandler;
|
private transient PipelineHookTriggerHandler pipelineTriggerHandler;
|
||||||
private transient boolean acceptMergeRequestOnSuccess;
|
private transient boolean acceptPullRequestOnSuccess;
|
||||||
private transient MergeRequestLabelFilter mergeRequestLabelFilter;
|
private transient PullRequestLabelFilter pullRequestLabelFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use {@link #GiteePushTrigger()} with setters to configure an instance of this class.
|
* @deprecated use {@link #GiteePushTrigger()} with setters to configure an instance of this class.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||||
public GiteePushTrigger(boolean triggerOnPush, boolean triggerOnOpenMergeRequest, boolean triggerOnUpdateMergeRequest, boolean triggerOnAcceptedMergeRequest, boolean triggerOnClosedMergeRequest,
|
public GiteePushTrigger(boolean triggerOnPush, boolean triggerOnOpenPullRequest, boolean triggerOnUpdatePullRequest, boolean triggerOnAcceptedPullRequest, boolean triggerOnClosedPullRequest,
|
||||||
boolean triggerOnNoteRequest, String noteRegex,
|
boolean triggerOnNoteRequest, String noteRegex,
|
||||||
boolean skipWorkInProgressMergeRequest, boolean ciSkip,
|
boolean skipWorkInProgressPullRequest, boolean ciSkip,
|
||||||
boolean setBuildDescription, boolean addNoteOnMergeRequest, boolean addCiMessage, boolean addVoteOnMergeRequest,
|
boolean setBuildDescription, boolean addNoteOnPullRequest, boolean addCiMessage, boolean addVoteOnPullRequest,
|
||||||
boolean acceptMergeRequestOnSuccess, BranchFilterType branchFilterType,
|
boolean acceptPullRequestOnSuccess, BranchFilterType branchFilterType,
|
||||||
String includeBranchesSpec, String excludeBranchesSpec, String targetBranchRegex,
|
String includeBranchesSpec, String excludeBranchesSpec, String targetBranchRegex,
|
||||||
MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig, String secretToken, boolean triggerOnPipelineEvent,
|
PullRequestLabelFilterConfig pullRequestLabelFilterConfig, String secretToken, boolean triggerOnPipelineEvent,
|
||||||
boolean triggerOnApprovedMergeRequest, String pendingBuildName, boolean cancelPendingBuildsOnUpdate) {
|
boolean triggerOnApprovedPullRequest, String pendingBuildName, boolean cancelPendingBuildsOnUpdate) {
|
||||||
this.triggerOnPush = triggerOnPush;
|
this.triggerOnPush = triggerOnPush;
|
||||||
this.triggerOnOpenMergeRequest = triggerOnOpenMergeRequest;
|
this.triggerOnOpenPullRequest = triggerOnOpenPullRequest;
|
||||||
this.triggerOnUpdateMergeRequest = triggerOnUpdateMergeRequest;
|
this.triggerOnUpdatePullRequest = triggerOnUpdatePullRequest;
|
||||||
this.triggerOnAcceptedMergeRequest = triggerOnAcceptedMergeRequest;
|
this.triggerOnAcceptedPullRequest = triggerOnAcceptedPullRequest;
|
||||||
this.triggerOnClosedMergeRequest = triggerOnClosedMergeRequest;
|
this.triggerOnClosedPullRequest = triggerOnClosedPullRequest;
|
||||||
this.triggerOnNoteRequest = triggerOnNoteRequest;
|
this.triggerOnNoteRequest = triggerOnNoteRequest;
|
||||||
this.noteRegex = noteRegex;
|
this.noteRegex = noteRegex;
|
||||||
this.triggerOnPipelineEvent = triggerOnPipelineEvent;
|
this.triggerOnPipelineEvent = triggerOnPipelineEvent;
|
||||||
this.ciSkip = ciSkip;
|
this.ciSkip = ciSkip;
|
||||||
this.skipWorkInProgressMergeRequest = skipWorkInProgressMergeRequest;
|
this.skipWorkInProgressPullRequest = skipWorkInProgressPullRequest;
|
||||||
this.setBuildDescription = setBuildDescription;
|
this.setBuildDescription = setBuildDescription;
|
||||||
this.addNoteOnMergeRequest = addNoteOnMergeRequest;
|
this.addNoteOnPullRequest = addNoteOnPullRequest;
|
||||||
this.addCiMessage = addCiMessage;
|
this.addCiMessage = addCiMessage;
|
||||||
this.addVoteOnMergeRequest = addVoteOnMergeRequest;
|
this.addVoteOnPullRequest = addVoteOnPullRequest;
|
||||||
this.branchFilterType = branchFilterType;
|
this.branchFilterType = branchFilterType;
|
||||||
this.includeBranchesSpec = includeBranchesSpec;
|
this.includeBranchesSpec = includeBranchesSpec;
|
||||||
this.excludeBranchesSpec = excludeBranchesSpec;
|
this.excludeBranchesSpec = excludeBranchesSpec;
|
||||||
this.targetBranchRegex = targetBranchRegex;
|
this.targetBranchRegex = targetBranchRegex;
|
||||||
this.acceptMergeRequestOnSuccess = acceptMergeRequestOnSuccess;
|
this.acceptPullRequestOnSuccess = acceptPullRequestOnSuccess;
|
||||||
this.mergeRequestLabelFilterConfig = mergeRequestLabelFilterConfig;
|
this.pullRequestLabelFilterConfig = pullRequestLabelFilterConfig;
|
||||||
this.secretToken = Secret.fromString(secretToken);
|
this.secretToken = Secret.fromString(secretToken);
|
||||||
this.triggerOnApprovedMergeRequest = triggerOnApprovedMergeRequest;
|
this.triggerOnApprovedPullRequest = triggerOnApprovedPullRequest;
|
||||||
this.pendingBuildName = pendingBuildName;
|
this.pendingBuildName = pendingBuildName;
|
||||||
this.cancelPendingBuildsOnUpdate = cancelPendingBuildsOnUpdate;
|
this.cancelPendingBuildsOnUpdate = cancelPendingBuildsOnUpdate;
|
||||||
|
|
||||||
initializeTriggerHandler();
|
initializeTriggerHandler();
|
||||||
initializeBranchFilter();
|
initializeBranchFilter();
|
||||||
initializeMergeRequestLabelFilter();
|
initializePullRequestLabelFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundConstructor
|
@DataBoundConstructor
|
||||||
|
@ -180,11 +176,11 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
|
for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
|
||||||
GiteePushTrigger trigger = project.getTrigger(GiteePushTrigger.class);
|
GiteePushTrigger trigger = project.getTrigger(GiteePushTrigger.class);
|
||||||
if (trigger != null) {
|
if (trigger != null) {
|
||||||
if (trigger.addNoteOnMergeRequest) {
|
if (trigger.addNoteOnPullRequest) {
|
||||||
project.getPublishersList().add(new GiteeMessagePublisher());
|
project.getPublishersList().add(new GiteeMessagePublisher());
|
||||||
}
|
}
|
||||||
if (trigger.acceptMergeRequestOnSuccess) {
|
if (trigger.acceptPullRequestOnSuccess) {
|
||||||
project.getPublishersList().add(new GiteeAcceptMergeRequestPublisher());
|
project.getPublishersList().add(new GiteeAcceptPullRequestPublisher());
|
||||||
}
|
}
|
||||||
project.save();
|
project.save();
|
||||||
}
|
}
|
||||||
|
@ -194,32 +190,34 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getAddNoteOnPullRequest() { return addNoteOnPullRequest; }
|
||||||
|
|
||||||
public boolean getTriggerOnPush() {
|
public boolean getTriggerOnPush() {
|
||||||
return triggerOnPush;
|
return triggerOnPush;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getTriggerOnOpenMergeRequest() {
|
public boolean getTriggerOnOpenPullRequest() {
|
||||||
return triggerOnOpenMergeRequest;
|
return triggerOnOpenPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getTriggerOnTestedMergeRequest() {
|
public boolean getTriggerOnTestedPullRequest() {
|
||||||
return triggerOnTestedMergeRequest;
|
return triggerOnTestedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getTriggerOnUpdateMergeRequest() {
|
public boolean getTriggerOnUpdatePullRequest() {
|
||||||
return triggerOnUpdateMergeRequest;
|
return triggerOnUpdatePullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTriggerOnAcceptedMergeRequest() {
|
public boolean isTriggerOnAcceptedPullRequest() {
|
||||||
return triggerOnAcceptedMergeRequest;
|
return triggerOnAcceptedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTriggerOnApprovedMergeRequest() {
|
public boolean isTriggerOnApprovedPullRequest() {
|
||||||
return triggerOnApprovedMergeRequest;
|
return triggerOnApprovedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTriggerOnClosedMergeRequest() {
|
public boolean isTriggerOnClosedPullRequest() {
|
||||||
return triggerOnClosedMergeRequest;
|
return triggerOnClosedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getTriggerOnNoteRequest() {
|
public boolean getTriggerOnNoteRequest() {
|
||||||
|
@ -244,8 +242,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
return skipLastCommitHasBeenBuild;
|
return skipLastCommitHasBeenBuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSkipWorkInProgressMergeRequest() {
|
public boolean isSkipWorkInProgressPullRequest() {
|
||||||
return skipWorkInProgressMergeRequest;
|
return skipWorkInProgressPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSkipLastCommitHasBuild() {
|
public boolean isSkipLastCommitHasBuild() {
|
||||||
|
@ -268,8 +266,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
return targetBranchRegex;
|
return targetBranchRegex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MergeRequestLabelFilterConfig getMergeRequestLabelFilterConfig() {
|
public PullRequestLabelFilterConfig getPullRequestLabelFilterConfig() {
|
||||||
return mergeRequestLabelFilterConfig;
|
return pullRequestLabelFilterConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSecretToken() {
|
public String getSecretToken() {
|
||||||
|
@ -290,28 +288,28 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setTriggerOnApprovedMergeRequest(boolean triggerOnApprovedMergeRequest) {
|
public void setTriggerOnApprovedPullRequest(boolean triggerOnApprovedPullRequest) {
|
||||||
this.triggerOnApprovedMergeRequest = triggerOnApprovedMergeRequest;
|
this.triggerOnApprovedPullRequest = triggerOnApprovedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setTriggerOnTestedMergeRequest(boolean triggerOnTestedMergeRequest) {
|
public void setTriggerOnTestedPullRequest(boolean triggerOnTestedPullRequest) {
|
||||||
this.triggerOnTestedMergeRequest = triggerOnTestedMergeRequest;
|
this.triggerOnTestedPullRequest = triggerOnTestedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setTriggerOnOpenMergeRequest(boolean triggerOnOpenMergeRequest) {
|
public void setTriggerOnOpenPullRequest(boolean triggerOnOpenPullRequest) {
|
||||||
this.triggerOnOpenMergeRequest = triggerOnOpenMergeRequest;
|
this.triggerOnOpenPullRequest = triggerOnOpenPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setTriggerOnAcceptedMergeRequest(boolean triggerOnAcceptedMergeRequest) {
|
public void setTriggerOnAcceptedPullRequest(boolean triggerOnAcceptedPullRequest) {
|
||||||
this.triggerOnAcceptedMergeRequest = triggerOnAcceptedMergeRequest;
|
this.triggerOnAcceptedPullRequest = triggerOnAcceptedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setTriggerOnClosedMergeRequest(boolean triggerOnClosedMergeRequest) {
|
public void setTriggerOnClosedPullRequest(boolean triggerOnClosedPullRequest) {
|
||||||
this.triggerOnClosedMergeRequest = triggerOnClosedMergeRequest;
|
this.triggerOnClosedPullRequest = triggerOnClosedPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
|
@ -330,8 +328,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setSkipWorkInProgressMergeRequest(boolean skipWorkInProgressMergeRequest) {
|
public void setSkipWorkInProgressPullRequest(boolean skipWorkInProgressPullRequest) {
|
||||||
this.skipWorkInProgressMergeRequest = skipWorkInProgressMergeRequest;
|
this.skipWorkInProgressPullRequest = skipWorkInProgressPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
|
@ -347,8 +345,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setAddNoteOnMergeRequest(boolean addNoteOnMergeRequest) {
|
public void setAddNoteOnPullRequest(boolean addNoteOnPullRequest) {
|
||||||
this.addNoteOnMergeRequest = addNoteOnMergeRequest;
|
this.addNoteOnPullRequest = addNoteOnPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
|
@ -357,8 +355,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setAddVoteOnMergeRequest(boolean addVoteOnMergeRequest) {
|
public void setAddVoteOnPullRequest(boolean addVoteOnPullRequest) {
|
||||||
this.addVoteOnMergeRequest = addVoteOnMergeRequest;
|
this.addVoteOnPullRequest = addVoteOnPullRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
|
@ -387,8 +385,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setMergeRequestLabelFilterConfig(MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig) {
|
public void setPullRequestLabelFilterConfig(PullRequestLabelFilterConfig pullRequestLabelFilterConfig) {
|
||||||
this.mergeRequestLabelFilterConfig = mergeRequestLabelFilterConfig;
|
this.pullRequestLabelFilterConfig = pullRequestLabelFilterConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
|
@ -397,13 +395,13 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setAcceptMergeRequestOnSuccess(boolean acceptMergeRequestOnSuccess) {
|
public void setAcceptPullRequestOnSuccess(boolean acceptPullRequestOnSuccess) {
|
||||||
this.acceptMergeRequestOnSuccess = acceptMergeRequestOnSuccess;
|
this.acceptPullRequestOnSuccess = acceptPullRequestOnSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setTriggerOnUpdateMergeRequest(boolean triggerOnUpdateMergeRequest) {
|
public void setTriggerOnUpdatePullRequest(boolean triggerOnUpdatePullRequest) {
|
||||||
this.triggerOnUpdateMergeRequest = triggerOnUpdateMergeRequest;
|
this.triggerOnUpdatePullRequest = triggerOnUpdatePullRequest;
|
||||||
}
|
}
|
||||||
@DataBoundSetter
|
@DataBoundSetter
|
||||||
public void setTriggerOnPipelineEvent(boolean triggerOnPipelineEvent) {
|
public void setTriggerOnPipelineEvent(boolean triggerOnPipelineEvent) {
|
||||||
|
@ -425,27 +423,27 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
if (branchFilter == null) {
|
if (branchFilter == null) {
|
||||||
initializeBranchFilter();
|
initializeBranchFilter();
|
||||||
}
|
}
|
||||||
if (mergeRequestLabelFilter == null) {
|
if (pullRequestLabelFilter == null) {
|
||||||
initializeMergeRequestLabelFilter();
|
initializePullRequestLabelFilter();
|
||||||
}
|
}
|
||||||
if (pushHookTriggerHandler == null) {
|
if (pushHookTriggerHandler == null) {
|
||||||
initializeTriggerHandler();
|
initializeTriggerHandler();
|
||||||
}
|
}
|
||||||
pushHookTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
pushHookTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// executes when the Trigger receives a merge request
|
// executes when the Trigger receives a pull request
|
||||||
public void onPost(final MergeRequestHook hook) {
|
public void onPost(final PullRequestHook hook) {
|
||||||
if (branchFilter == null) {
|
if (branchFilter == null) {
|
||||||
initializeBranchFilter();
|
initializeBranchFilter();
|
||||||
}
|
}
|
||||||
if (mergeRequestLabelFilter == null) {
|
if (pullRequestLabelFilter == null) {
|
||||||
initializeMergeRequestLabelFilter();
|
initializePullRequestLabelFilter();
|
||||||
}
|
}
|
||||||
if (mergeRequestHookTriggerHandler == null) {
|
if (pullRequestHookTriggerHandler == null) {
|
||||||
initializeTriggerHandler();
|
initializeTriggerHandler();
|
||||||
}
|
}
|
||||||
mergeRequestHookTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
pullRequestHookTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// executes when the Trigger receives a note request
|
// executes when the Trigger receives a note request
|
||||||
|
@ -453,13 +451,13 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
if (branchFilter == null) {
|
if (branchFilter == null) {
|
||||||
initializeBranchFilter();
|
initializeBranchFilter();
|
||||||
}
|
}
|
||||||
if (mergeRequestLabelFilter == null) {
|
if (pullRequestLabelFilter == null) {
|
||||||
initializeMergeRequestLabelFilter();
|
initializePullRequestLabelFilter();
|
||||||
}
|
}
|
||||||
if (noteHookTriggerHandler == null) {
|
if (noteHookTriggerHandler == null) {
|
||||||
initializeTriggerHandler();
|
initializeTriggerHandler();
|
||||||
}
|
}
|
||||||
noteHookTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
noteHookTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// executes when the Trigger receives a pipeline event
|
// executes when the Trigger receives a pipeline event
|
||||||
|
@ -467,15 +465,15 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
if (pipelineTriggerHandler == null) {
|
if (pipelineTriggerHandler == null) {
|
||||||
initializeTriggerHandler();
|
initializeTriggerHandler();
|
||||||
}
|
}
|
||||||
pipelineTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
pipelineTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTriggerHandler() {
|
private void initializeTriggerHandler() {
|
||||||
mergeRequestHookTriggerHandler = newMergeRequestHookTriggerHandler(triggerOnOpenMergeRequest,
|
pullRequestHookTriggerHandler = newPullRequestHookTriggerHandler(triggerOnOpenPullRequest,
|
||||||
triggerOnUpdateMergeRequest, triggerOnAcceptedMergeRequest, triggerOnClosedMergeRequest,
|
triggerOnUpdatePullRequest, triggerOnAcceptedPullRequest, triggerOnClosedPullRequest,
|
||||||
skipWorkInProgressMergeRequest, triggerOnApprovedMergeRequest, triggerOnTestedMergeRequest, cancelPendingBuildsOnUpdate);
|
skipWorkInProgressPullRequest, triggerOnApprovedPullRequest, triggerOnTestedPullRequest, cancelPendingBuildsOnUpdate);
|
||||||
noteHookTriggerHandler = newNoteHookTriggerHandler(triggerOnNoteRequest, noteRegex);
|
noteHookTriggerHandler = newNoteHookTriggerHandler(triggerOnNoteRequest, noteRegex);
|
||||||
pushHookTriggerHandler = newPushHookTriggerHandler(triggerOnPush, skipWorkInProgressMergeRequest);
|
pushHookTriggerHandler = newPushHookTriggerHandler(triggerOnPush, skipWorkInProgressPullRequest);
|
||||||
pipelineTriggerHandler = newPipelineHookTriggerHandler(triggerOnPipelineEvent);
|
pipelineTriggerHandler = newPipelineHookTriggerHandler(triggerOnPipelineEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,15 +489,15 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
||||||
.build(branchFilterType));
|
.build(branchFilterType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeMergeRequestLabelFilter() {
|
private void initializePullRequestLabelFilter() {
|
||||||
mergeRequestLabelFilter = MergeRequestLabelFilterFactory.newMergeRequestLabelFilter(mergeRequestLabelFilterConfig);
|
pullRequestLabelFilter = PullRequestLabelFilterFactory.newPullRequestLabelFilter(pullRequestLabelFilterConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object readResolve() throws ObjectStreamException {
|
protected Object readResolve() throws ObjectStreamException {
|
||||||
initializeTriggerHandler();
|
initializeTriggerHandler();
|
||||||
initializeBranchFilter();
|
initializeBranchFilter();
|
||||||
initializeMergeRequestLabelFilter();
|
initializePullRequestLabelFilter();
|
||||||
return super.readResolve();
|
return super.readResolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.gitee.jenkins.trigger.filter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robin Müller
|
|
||||||
*/
|
|
||||||
public class MergeRequestLabelFilterFactory {
|
|
||||||
|
|
||||||
private MergeRequestLabelFilterFactory() { }
|
|
||||||
|
|
||||||
public static MergeRequestLabelFilter newMergeRequestLabelFilter(MergeRequestLabelFilterConfig config) {
|
|
||||||
if (config == null) {
|
|
||||||
return new NopMergeRequestLabelFilter();
|
|
||||||
} else {
|
|
||||||
return new MergeRequestLabelFilterImpl(config.getInclude(), config.getExclude());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,9 +5,9 @@ import java.util.Collection;
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
class NopMergeRequestLabelFilter implements MergeRequestLabelFilter {
|
class NopPullRequestLabelFilter implements PullRequestLabelFilter {
|
||||||
@Override
|
@Override
|
||||||
public boolean isMergeRequestAllowed(Collection<String> labels) {
|
public boolean isPullRequestAllowed(Collection<String> labels) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,6 @@ import java.util.Collection;
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
public interface MergeRequestLabelFilter {
|
public interface PullRequestLabelFilter {
|
||||||
boolean isMergeRequestAllowed(Collection<String> labels);
|
boolean isPullRequestAllowed(Collection<String> labels);
|
||||||
}
|
}
|
|
@ -6,22 +6,22 @@ import org.kohsuke.stapler.DataBoundSetter;
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
public class MergeRequestLabelFilterConfig {
|
public class PullRequestLabelFilterConfig {
|
||||||
|
|
||||||
private String include;
|
private String include;
|
||||||
private String exclude;
|
private String exclude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use {@link #MergeRequestLabelFilterConfig()} with setters to configure an instance of this class.
|
* @deprecated use {@link #PullRequestLabelFilterConfig()} with setters to configure an instance of this class.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public MergeRequestLabelFilterConfig(String include, String exclude) {
|
public PullRequestLabelFilterConfig(String include, String exclude) {
|
||||||
this.include = include;
|
this.include = include;
|
||||||
this.exclude = exclude;
|
this.exclude = exclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataBoundConstructor
|
@DataBoundConstructor
|
||||||
public MergeRequestLabelFilterConfig() { }
|
public PullRequestLabelFilterConfig() { }
|
||||||
|
|
||||||
public String getInclude() {
|
public String getInclude() {
|
||||||
return include;
|
return include;
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.gitee.jenkins.trigger.filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robin Müller
|
||||||
|
*/
|
||||||
|
public class PullRequestLabelFilterFactory {
|
||||||
|
|
||||||
|
private PullRequestLabelFilterFactory() { }
|
||||||
|
|
||||||
|
public static PullRequestLabelFilter newPullRequestLabelFilter(PullRequestLabelFilterConfig config) {
|
||||||
|
if (config == null) {
|
||||||
|
return new NopPullRequestLabelFilter();
|
||||||
|
} else {
|
||||||
|
return new PullRequestLabelFilterImpl(config.getInclude(), config.getExclude());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,18 +9,18 @@ import java.util.Set;
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
class MergeRequestLabelFilterImpl implements MergeRequestLabelFilter {
|
class PullRequestLabelFilterImpl implements PullRequestLabelFilter {
|
||||||
|
|
||||||
private final Set<String> includeLabels;
|
private final Set<String> includeLabels;
|
||||||
private final Set<String> excludeLabels;
|
private final Set<String> excludeLabels;
|
||||||
|
|
||||||
public MergeRequestLabelFilterImpl(String includeLabels, String excludeLabels) {
|
public PullRequestLabelFilterImpl(String includeLabels, String excludeLabels) {
|
||||||
this.includeLabels = convert(includeLabels);
|
this.includeLabels = convert(includeLabels);
|
||||||
this.excludeLabels = convert(excludeLabels);
|
this.excludeLabels = convert(excludeLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMergeRequestAllowed(Collection<String> labels) {
|
public boolean isPullRequestAllowed(Collection<String> labels) {
|
||||||
return containsNoExcludeLabel(labels) && containsIncludeLabel(labels);
|
return containsNoExcludeLabel(labels) && containsIncludeLabel(labels);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.gitee.jenkins.cause.GiteeWebHookCause;
|
||||||
import com.gitee.jenkins.gitee.hook.model.WebHook;
|
import com.gitee.jenkins.gitee.hook.model.WebHook;
|
||||||
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import com.gitee.jenkins.util.LoggerUtil;
|
import com.gitee.jenkins.util.LoggerUtil;
|
||||||
import hudson.model.Action;
|
import hudson.model.Action;
|
||||||
import hudson.model.CauseAction;
|
import hudson.model.CauseAction;
|
||||||
|
@ -34,7 +34,7 @@ public abstract class AbstractWebHookTriggerHandler<H extends WebHook> implement
|
||||||
protected PendingBuildsHandler pendingBuildsHandler = new PendingBuildsHandler();
|
protected PendingBuildsHandler pendingBuildsHandler = new PendingBuildsHandler();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, H hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, H hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
if (ciSkip && isCiSkip(hook)) {
|
if (ciSkip && isCiSkip(hook)) {
|
||||||
LOGGER.log(Level.INFO, "Skipping due to ci-skip.");
|
LOGGER.log(Level.INFO, "Skipping due to ci-skip.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler;
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.WebHook;
|
import com.gitee.jenkins.gitee.hook.model.WebHook;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,5 +10,5 @@ import hudson.model.Job;
|
||||||
*/
|
*/
|
||||||
public interface WebHookTriggerHandler<H extends WebHook> {
|
public interface WebHookTriggerHandler<H extends WebHook> {
|
||||||
|
|
||||||
void handle(Job<?, ?> job, H hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter);
|
void handle(Job<?, ?> job, H hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
package com.gitee.jenkins.trigger.handler.merge;
|
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestHook;
|
|
||||||
import com.gitee.jenkins.trigger.handler.WebHookTriggerHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robin Müller
|
|
||||||
*/
|
|
||||||
public interface MergeRequestHookTriggerHandler extends WebHookTriggerHandler<MergeRequestHook> { }
|
|
|
@ -1,115 +0,0 @@
|
||||||
package com.gitee.jenkins.trigger.handler.merge;
|
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.Action;
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.State;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robin Müller
|
|
||||||
*/
|
|
||||||
public final class MergeRequestHookTriggerHandlerFactory {
|
|
||||||
|
|
||||||
private MergeRequestHookTriggerHandlerFactory() {}
|
|
||||||
|
|
||||||
public static MergeRequestHookTriggerHandler newMergeRequestHookTriggerHandler(boolean triggerOnOpenMergeRequest,
|
|
||||||
boolean triggerOnUpdateMergeRequest,
|
|
||||||
boolean triggerOnAcceptedMergeRequest,
|
|
||||||
boolean triggerOnClosedMergeRequest,
|
|
||||||
boolean skipWorkInProgressMergeRequest,
|
|
||||||
boolean triggerOnApprovedMergeRequest,
|
|
||||||
boolean triggerOnTestedMergeRequest,
|
|
||||||
boolean cancelPendingBuildsOnUpdate) {
|
|
||||||
if (triggerOnOpenMergeRequest
|
|
||||||
|| triggerOnUpdateMergeRequest
|
|
||||||
|| triggerOnAcceptedMergeRequest
|
|
||||||
|| triggerOnClosedMergeRequest
|
|
||||||
|| triggerOnApprovedMergeRequest
|
|
||||||
|| triggerOnTestedMergeRequest) {
|
|
||||||
|
|
||||||
return new MergeRequestHookTriggerHandlerImpl(
|
|
||||||
retrieveAllowedStates(triggerOnOpenMergeRequest,
|
|
||||||
triggerOnUpdateMergeRequest,
|
|
||||||
triggerOnAcceptedMergeRequest,
|
|
||||||
triggerOnClosedMergeRequest,
|
|
||||||
triggerOnApprovedMergeRequest,
|
|
||||||
triggerOnTestedMergeRequest),
|
|
||||||
retrieveAllowedActions(triggerOnOpenMergeRequest,
|
|
||||||
triggerOnUpdateMergeRequest,
|
|
||||||
triggerOnAcceptedMergeRequest,
|
|
||||||
triggerOnClosedMergeRequest,
|
|
||||||
triggerOnApprovedMergeRequest,
|
|
||||||
triggerOnTestedMergeRequest),
|
|
||||||
skipWorkInProgressMergeRequest,
|
|
||||||
cancelPendingBuildsOnUpdate);
|
|
||||||
} else {
|
|
||||||
return new NopMergeRequestHookTriggerHandler();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<Action> retrieveAllowedActions(boolean triggerOnOpenMergeRequest,
|
|
||||||
boolean triggerOnUpdateMergeRequest,
|
|
||||||
boolean triggerOnAcceptedMergeRequest,
|
|
||||||
boolean triggerOnClosedMergeRequest,
|
|
||||||
boolean triggerOnApprovedMergeRequest,
|
|
||||||
boolean triggerOnTestedMergeRequest) {
|
|
||||||
List<Action> allowedActions =new ArrayList<>();
|
|
||||||
|
|
||||||
if (triggerOnOpenMergeRequest) {
|
|
||||||
allowedActions.add(Action.open);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (triggerOnUpdateMergeRequest) {
|
|
||||||
allowedActions.add(Action.update);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (triggerOnAcceptedMergeRequest) {
|
|
||||||
allowedActions.add(Action.merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (triggerOnClosedMergeRequest) {
|
|
||||||
allowedActions.add(Action.close);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (triggerOnApprovedMergeRequest) {
|
|
||||||
allowedActions.add(Action.approved);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (triggerOnTestedMergeRequest) {
|
|
||||||
allowedActions.add(Action.tested);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allowedActions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<State> retrieveAllowedStates(boolean triggerOnOpenMergeRequest,
|
|
||||||
boolean triggerOnUpdateMergeRequest,
|
|
||||||
boolean triggerOnAcceptedMergeRequest,
|
|
||||||
boolean triggerOnClosedMergeRequest,
|
|
||||||
boolean triggerOnApprovedMergeRequest,
|
|
||||||
boolean triggerOnTestedMergeRequest) {
|
|
||||||
List<State> result = new ArrayList<>();
|
|
||||||
if (triggerOnOpenMergeRequest
|
|
||||||
|| triggerOnUpdateMergeRequest
|
|
||||||
|| triggerOnApprovedMergeRequest
|
|
||||||
|| triggerOnTestedMergeRequest) {
|
|
||||||
|
|
||||||
result.add(State.opened);
|
|
||||||
result.add(State.open);
|
|
||||||
result.add(State.reopened);
|
|
||||||
result.add(State.updated);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (triggerOnAcceptedMergeRequest) {
|
|
||||||
result.add(State.merged);
|
|
||||||
}
|
|
||||||
if (triggerOnClosedMergeRequest) {
|
|
||||||
result.add(State.closed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.gitee.jenkins.trigger.handler.merge;
|
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestHook;
|
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
|
||||||
import hudson.model.Job;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robin Müller
|
|
||||||
*/
|
|
||||||
class NopMergeRequestHookTriggerHandler implements MergeRequestHookTriggerHandler {
|
|
||||||
@Override
|
|
||||||
public void handle(Job<?, ?> job, MergeRequestHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.gitee.jenkins.trigger.handler.merge;
|
||||||
|
|
||||||
|
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||||
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
|
import hudson.model.Job;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robin Müller
|
||||||
|
*/
|
||||||
|
class NopPullRequestHookTriggerHandler implements PullRequestHookTriggerHandler {
|
||||||
|
@Override
|
||||||
|
public void handle(Job<?, ?> job, PullRequestHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.gitee.jenkins.trigger.handler.merge;
|
||||||
|
|
||||||
|
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||||
|
import com.gitee.jenkins.trigger.handler.WebHookTriggerHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robin Müller
|
||||||
|
*/
|
||||||
|
public interface PullRequestHookTriggerHandler extends WebHookTriggerHandler<PullRequestHook> { }
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.gitee.jenkins.trigger.handler.merge;
|
||||||
|
|
||||||
|
import com.gitee.jenkins.gitee.hook.model.Action;
|
||||||
|
import com.gitee.jenkins.gitee.hook.model.State;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robin Müller
|
||||||
|
*/
|
||||||
|
public final class PullRequestHookTriggerHandlerFactory {
|
||||||
|
|
||||||
|
private PullRequestHookTriggerHandlerFactory() {}
|
||||||
|
|
||||||
|
public static PullRequestHookTriggerHandler newPullRequestHookTriggerHandler(boolean triggerOnOpenPullRequest,
|
||||||
|
boolean triggerOnUpdatePullRequest,
|
||||||
|
boolean triggerOnAcceptedPullRequest,
|
||||||
|
boolean triggerOnClosedPullRequest,
|
||||||
|
boolean skipWorkInProgressPullRequest,
|
||||||
|
boolean triggerOnApprovedPullRequest,
|
||||||
|
boolean triggerOnTestedPullRequest,
|
||||||
|
boolean cancelPendingBuildsOnUpdate) {
|
||||||
|
if (triggerOnOpenPullRequest
|
||||||
|
|| triggerOnUpdatePullRequest
|
||||||
|
|| triggerOnAcceptedPullRequest
|
||||||
|
|| triggerOnClosedPullRequest
|
||||||
|
|| triggerOnApprovedPullRequest
|
||||||
|
|| triggerOnTestedPullRequest) {
|
||||||
|
|
||||||
|
return new PullRequestHookTriggerHandlerImpl(
|
||||||
|
retrieveAllowedStates(triggerOnOpenPullRequest,
|
||||||
|
triggerOnUpdatePullRequest,
|
||||||
|
triggerOnAcceptedPullRequest,
|
||||||
|
triggerOnClosedPullRequest,
|
||||||
|
triggerOnApprovedPullRequest,
|
||||||
|
triggerOnTestedPullRequest),
|
||||||
|
retrieveAllowedActions(triggerOnOpenPullRequest,
|
||||||
|
triggerOnUpdatePullRequest,
|
||||||
|
triggerOnAcceptedPullRequest,
|
||||||
|
triggerOnClosedPullRequest,
|
||||||
|
triggerOnApprovedPullRequest,
|
||||||
|
triggerOnTestedPullRequest),
|
||||||
|
skipWorkInProgressPullRequest,
|
||||||
|
cancelPendingBuildsOnUpdate);
|
||||||
|
} else {
|
||||||
|
return new NopPullRequestHookTriggerHandler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Action> retrieveAllowedActions(boolean triggerOnOpenPullRequest,
|
||||||
|
boolean triggerOnUpdatePullRequest,
|
||||||
|
boolean triggerOnAcceptedPullRequest,
|
||||||
|
boolean triggerOnClosedPullRequest,
|
||||||
|
boolean triggerOnApprovedPullRequest,
|
||||||
|
boolean triggerOnTestedPullRequest) {
|
||||||
|
List<Action> allowedActions =new ArrayList<>();
|
||||||
|
|
||||||
|
if (triggerOnOpenPullRequest) {
|
||||||
|
allowedActions.add(Action.open);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triggerOnUpdatePullRequest) {
|
||||||
|
allowedActions.add(Action.update);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triggerOnAcceptedPullRequest) {
|
||||||
|
allowedActions.add(Action.merge);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triggerOnClosedPullRequest) {
|
||||||
|
allowedActions.add(Action.close);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triggerOnApprovedPullRequest) {
|
||||||
|
allowedActions.add(Action.approved);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triggerOnTestedPullRequest) {
|
||||||
|
allowedActions.add(Action.tested);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowedActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<State> retrieveAllowedStates(boolean triggerOnOpenPullRequest,
|
||||||
|
boolean triggerOnUpdatePullRequest,
|
||||||
|
boolean triggerOnAcceptedPullRequest,
|
||||||
|
boolean triggerOnClosedPullRequest,
|
||||||
|
boolean triggerOnApprovedPullRequest,
|
||||||
|
boolean triggerOnTestedPullRequest) {
|
||||||
|
List<State> result = new ArrayList<>();
|
||||||
|
if (triggerOnOpenPullRequest
|
||||||
|
|| triggerOnUpdatePullRequest
|
||||||
|
|| triggerOnApprovedPullRequest
|
||||||
|
|| triggerOnTestedPullRequest) {
|
||||||
|
|
||||||
|
result.add(State.opened);
|
||||||
|
result.add(State.open);
|
||||||
|
result.add(State.reopened);
|
||||||
|
result.add(State.updated);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triggerOnAcceptedPullRequest) {
|
||||||
|
result.add(State.merged);
|
||||||
|
}
|
||||||
|
if (triggerOnClosedPullRequest) {
|
||||||
|
result.add(State.closed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,14 +2,15 @@ package com.gitee.jenkins.trigger.handler.merge;
|
||||||
|
|
||||||
import com.gitee.jenkins.cause.CauseData;
|
import com.gitee.jenkins.cause.CauseData;
|
||||||
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
||||||
import com.gitee.jenkins.gitee.hook.model.Action;
|
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestHook;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestObjectAttributes;
|
import com.gitee.jenkins.gitee.hook.model.*;
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestLabel;
|
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||||
import com.gitee.jenkins.gitee.hook.model.State;
|
import com.gitee.jenkins.publisher.GiteeMessagePublisher;
|
||||||
|
import com.gitee.jenkins.trigger.GiteePushTrigger;
|
||||||
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||||
import com.gitee.jenkins.util.BuildUtil;
|
import com.gitee.jenkins.util.BuildUtil;
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
|
@ -27,48 +28,60 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import static com.gitee.jenkins.cause.CauseDataBuilder.causeData;
|
import static com.gitee.jenkins.cause.CauseDataBuilder.causeData;
|
||||||
import static com.gitee.jenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
import static com.gitee.jenkins.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||||
|
import static com.gitee.jenkins.connection.GiteeConnectionProperty.getClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
* @author Yashin Luo
|
* @author Yashin Luo
|
||||||
*/
|
*/
|
||||||
class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<MergeRequestHook> implements MergeRequestHookTriggerHandler {
|
class PullRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<PullRequestHook> implements PullRequestHookTriggerHandler {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(MergeRequestHookTriggerHandlerImpl.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(PullRequestHookTriggerHandlerImpl.class.getName());
|
||||||
|
|
||||||
private final Collection<State> allowedStates;
|
private final Collection<State> allowedStates;
|
||||||
private final boolean skipWorkInProgressMergeRequest;
|
private final boolean skipWorkInProgressPullRequest;
|
||||||
private final Collection<Action> allowedActions;
|
private final Collection<Action> allowedActions;
|
||||||
private final boolean cancelPendingBuildsOnUpdate;
|
private final boolean cancelPendingBuildsOnUpdate;
|
||||||
|
|
||||||
MergeRequestHookTriggerHandlerImpl(Collection<State> allowedStates, boolean skipWorkInProgressMergeRequest, boolean cancelPendingBuildsOnUpdate) {
|
PullRequestHookTriggerHandlerImpl(Collection<State> allowedStates, boolean skipWorkInProgressPullRequest, boolean cancelPendingBuildsOnUpdate) {
|
||||||
this(allowedStates, EnumSet.allOf(Action.class), skipWorkInProgressMergeRequest, cancelPendingBuildsOnUpdate);
|
this(allowedStates, EnumSet.allOf(Action.class), skipWorkInProgressPullRequest, cancelPendingBuildsOnUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeRequestHookTriggerHandlerImpl(Collection<State> allowedStates, Collection<Action> allowedActions, boolean skipWorkInProgressMergeRequest, boolean cancelPendingBuildsOnUpdate) {
|
PullRequestHookTriggerHandlerImpl(Collection<State> allowedStates, Collection<Action> allowedActions, boolean skipWorkInProgressPullRequest, boolean cancelPendingBuildsOnUpdate) {
|
||||||
this.allowedStates = allowedStates;
|
this.allowedStates = allowedStates;
|
||||||
this.allowedActions = allowedActions;
|
this.allowedActions = allowedActions;
|
||||||
this.skipWorkInProgressMergeRequest = skipWorkInProgressMergeRequest;
|
this.skipWorkInProgressPullRequest = skipWorkInProgressPullRequest;
|
||||||
this.cancelPendingBuildsOnUpdate = cancelPendingBuildsOnUpdate;
|
this.cancelPendingBuildsOnUpdate = cancelPendingBuildsOnUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, MergeRequestHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, PullRequestHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
MergeRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
PullRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.log(Level.INFO, "request hook state=" + hook.getState() + ", action = " + hook.getAction() + " pr iid = " + objectAttributes.getNumber() + " hook name = " + hook.getHookName());
|
LOGGER.log(Level.INFO, "request hook state=" + hook.getState() + ", action = " + hook.getAction() + " pr iid = " + objectAttributes.getNumber() + " hook name = " + hook.getHookName());
|
||||||
if (isAllowedByConfig(hook)
|
if (isAllowedByConfig(hook)
|
||||||
&& isNotSkipWorkInProgressMergeRequest(objectAttributes)) {
|
&& isNotSkipWorkInProgressPullRequest(objectAttributes)) {
|
||||||
List<String> labelsNames = new ArrayList<>();
|
List<String> labelsNames = new ArrayList<>();
|
||||||
if (hook.getLabels() != null) {
|
if (hook.getLabels() != null) {
|
||||||
for (MergeRequestLabel label : hook.getLabels()) {
|
for (PullRequestLabel label : hook.getLabels()) {
|
||||||
labelsNames.add(label.getTitle());
|
labelsNames.add(label.getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mergeRequestLabelFilter.isMergeRequestAllowed(labelsNames)) {
|
// 若pr不可自动合并则评论至pr
|
||||||
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
if (!objectAttributes.can_be_merged()) {
|
||||||
|
LOGGER.log(Level.INFO, "This pull request can not be merge");
|
||||||
|
GiteeMessagePublisher publisher = GiteeMessagePublisher.getFromJob(job);
|
||||||
|
if (publisher != null) {
|
||||||
|
GiteeClient client = getClient(job);
|
||||||
|
PullRequest pullRequest = new PullRequest(objectAttributes);
|
||||||
|
LOGGER.log(Level.INFO, "sending message to gitee.....");
|
||||||
|
client.createPullRequestNote(pullRequest, ":bangbang: This pull request can not be merge! Please manual merge conflict.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (pullRequestLabelFilter.isPullRequestAllowed(labelsNames)) {
|
||||||
|
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -82,15 +95,15 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCiSkip(MergeRequestHook hook) {
|
protected boolean isCiSkip(PullRequestHook hook) {
|
||||||
return hook.getPullRequest() != null
|
return hook.getPullRequest() != null
|
||||||
&& hook.getPullRequest().getBody() != null
|
&& hook.getPullRequest().getBody() != null
|
||||||
&& hook.getPullRequest().getBody().contains("[ci-skip]");
|
&& hook.getPullRequest().getBody().contains("[ci-skip]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCommitSkip(Job<?, ?> project, MergeRequestHook hook) {
|
protected boolean isCommitSkip(Job<?, ?> project, PullRequestHook hook) {
|
||||||
MergeRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
PullRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
||||||
|
|
||||||
if (objectAttributes != null && objectAttributes.getMergeCommitSha() != null) {
|
if (objectAttributes != null && objectAttributes.getMergeCommitSha() != null) {
|
||||||
Run<?, ?> mergeBuild = BuildUtil.getBuildBySHA1IncludingMergeBuilds(project, objectAttributes.getMergeCommitSha());
|
Run<?, ?> mergeBuild = BuildUtil.getBuildBySHA1IncludingMergeBuilds(project, objectAttributes.getMergeCommitSha());
|
||||||
|
@ -103,7 +116,7 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cancelPendingBuildsIfNecessary(Job<?, ?> job, MergeRequestHook hook) {
|
protected void cancelPendingBuildsIfNecessary(Job<?, ?> job, PullRequestHook hook) {
|
||||||
if (!this.cancelPendingBuildsOnUpdate) {
|
if (!this.cancelPendingBuildsOnUpdate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -114,17 +127,17 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTargetBranch(MergeRequestHook hook) {
|
protected String getTargetBranch(PullRequestHook hook) {
|
||||||
return hook.getPullRequest() == null ? null : hook.getPullRequest().getTargetBranch();
|
return hook.getPullRequest() == null ? null : hook.getPullRequest().getTargetBranch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTriggerType() {
|
protected String getTriggerType() {
|
||||||
return "merge request";
|
return "pull request";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CauseData retrieveCauseData(MergeRequestHook hook) {
|
protected CauseData retrieveCauseData(PullRequestHook hook) {
|
||||||
return causeData()
|
return causeData()
|
||||||
.withActionType(CauseData.ActionType.MERGE)
|
.withActionType(CauseData.ActionType.MERGE)
|
||||||
.withSourceProjectId(hook.getPullRequest().getSourceProjectId())
|
.withSourceProjectId(hook.getPullRequest().getSourceProjectId())
|
||||||
|
@ -139,14 +152,14 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
||||||
.withSourceRepoUrl(hook.getPullRequest().getSource().getUrl())
|
.withSourceRepoUrl(hook.getPullRequest().getSource().getUrl())
|
||||||
.withSourceRepoSshUrl(hook.getPullRequest().getSource().getSshUrl())
|
.withSourceRepoSshUrl(hook.getPullRequest().getSource().getSshUrl())
|
||||||
.withSourceRepoHttpUrl(hook.getPullRequest().getSource().getGitHttpUrl())
|
.withSourceRepoHttpUrl(hook.getPullRequest().getSource().getGitHttpUrl())
|
||||||
.withMergeRequestTitle(hook.getPullRequest().getTitle())
|
.withPullRequestTitle(hook.getPullRequest().getTitle())
|
||||||
.withMergeRequestDescription(hook.getPullRequest().getBody())
|
.withPullRequestDescription(hook.getPullRequest().getBody())
|
||||||
.withMergeRequestId(hook.getPullRequest().getId())
|
.withPullRequestId(hook.getPullRequest().getId())
|
||||||
.withMergeRequestIid(hook.getPullRequest().getNumber())
|
.withPullRequestIid(hook.getPullRequest().getNumber())
|
||||||
.withMergeRequestState(hook.getState().toString())
|
.withPullRequestState(hook.getState().toString())
|
||||||
.withMergedByUser(hook.getUser() == null ? null : hook.getUser().getUsername())
|
.withMergedByUser(hook.getUser() == null ? null : hook.getUser().getUsername())
|
||||||
.withMergeRequestAssignee(hook.getAssignee() == null ? null : hook.getAssignee().getUsername())
|
.withPullRequestAssignee(hook.getAssignee() == null ? null : hook.getAssignee().getUsername())
|
||||||
.withMergeRequestTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
.withPullRequestTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
||||||
.withTargetBranch(hook.getPullRequest().getTargetBranch())
|
.withTargetBranch(hook.getPullRequest().getTargetBranch())
|
||||||
.withTargetRepoName(hook.getPullRequest().getTarget().getName())
|
.withTargetRepoName(hook.getPullRequest().getTarget().getName())
|
||||||
.withTargetNamespace(hook.getPullRequest().getTarget().getNamespace())
|
.withTargetNamespace(hook.getPullRequest().getTarget().getNamespace())
|
||||||
|
@ -160,12 +173,12 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RevisionParameterAction createRevisionParameter(MergeRequestHook hook, GitSCM gitSCM) throws NoRevisionToBuildException {
|
protected RevisionParameterAction createRevisionParameter(PullRequestHook hook, GitSCM gitSCM) throws NoRevisionToBuildException {
|
||||||
return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook, gitSCM));
|
return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook, gitSCM));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BuildStatusUpdate retrieveBuildStatusUpdate(MergeRequestHook hook) {
|
protected BuildStatusUpdate retrieveBuildStatusUpdate(PullRequestHook hook) {
|
||||||
return buildStatusUpdate()
|
return buildStatusUpdate()
|
||||||
.withProjectId(hook.getPullRequest().getSourceProjectId())
|
.withProjectId(hook.getPullRequest().getSourceProjectId())
|
||||||
.withSha(hook.getPullRequest().getMergeCommitSha())
|
.withSha(hook.getPullRequest().getMergeCommitSha())
|
||||||
|
@ -173,9 +186,9 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String retrieveRevisionToBuild(MergeRequestHook hook) throws NoRevisionToBuildException {
|
private String retrieveRevisionToBuild(PullRequestHook hook) throws NoRevisionToBuildException {
|
||||||
if (hook.getPullRequest() != null
|
if (hook.getPullRequest() != null
|
||||||
&& hook.getPullRequest().getMergeReferenceName() != null) {
|
&& hook.getPullRequest().getMergeReferenceName() != null) {
|
||||||
return hook.getPullRequest().getMergeReferenceName();
|
return hook.getPullRequest().getMergeReferenceName();
|
||||||
} else {
|
} else {
|
||||||
throw new NoRevisionToBuildException();
|
throw new NoRevisionToBuildException();
|
||||||
|
@ -187,15 +200,15 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
||||||
return cause == null ? null : cause.getData().getTargetBranch();
|
return cause == null ? null : cause.getData().getTargetBranch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAllowedByConfig(MergeRequestHook hook) {
|
private boolean isAllowedByConfig(PullRequestHook hook) {
|
||||||
return allowedStates.contains(hook.getState())
|
return allowedStates.contains(hook.getState())
|
||||||
&& allowedActions.contains(hook.getAction());
|
&& allowedActions.contains(hook.getAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gitee 无此状态,暂时屏蔽
|
// Gitee 无此状态,暂时屏蔽
|
||||||
private boolean isNotSkipWorkInProgressMergeRequest(MergeRequestObjectAttributes objectAttributes) {
|
private boolean isNotSkipWorkInProgressPullRequest(PullRequestObjectAttributes objectAttributes) {
|
||||||
// Boolean workInProgress = objectAttributes.getWorkInProgress();
|
// Boolean workInProgress = objectAttributes.getWorkInProgress();
|
||||||
// if (skipWorkInProgressMergeRequest && workInProgress != null && workInProgress) {
|
// if (skipWorkInProgressPullRequest && workInProgress != null && workInProgress) {
|
||||||
// LOGGER.log(Level.INFO, "Skip WIP Merge Request #{0} ({1})", toArray(objectAttributes.getNumber(), objectAttributes.getTitle()));
|
// LOGGER.log(Level.INFO, "Skip WIP Merge Request #{0} ({1})", toArray(objectAttributes.getNumber(), objectAttributes.getTitle()));
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler.note;
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.NoteHook;
|
import com.gitee.jenkins.gitee.hook.model.NoteHook;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,7 @@ import hudson.model.Job;
|
||||||
*/
|
*/
|
||||||
class NopNoteHookTriggerHandler implements NoteHookTriggerHandler {
|
class NopNoteHookTriggerHandler implements NoteHookTriggerHandler {
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, NoteHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, NoteHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,15 @@ package com.gitee.jenkins.trigger.handler.note;
|
||||||
|
|
||||||
import com.gitee.jenkins.cause.CauseData;
|
import com.gitee.jenkins.cause.CauseData;
|
||||||
import com.gitee.jenkins.gitee.hook.model.NoteHook;
|
import com.gitee.jenkins.gitee.hook.model.NoteHook;
|
||||||
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
|
||||||
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||||
import com.gitee.jenkins.util.BuildUtil;
|
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
import hudson.model.Run;
|
|
||||||
import hudson.plugins.git.GitSCM;
|
import hudson.plugins.git.GitSCM;
|
||||||
import hudson.plugins.git.RevisionParameterAction;
|
import hudson.plugins.git.RevisionParameterAction;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -36,17 +32,17 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, NoteHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, NoteHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
if (isValidTriggerPhrase(hook.getObjectAttributes().getNote())) {
|
if (isValidTriggerPhrase(hook.getObjectAttributes().getNote())) {
|
||||||
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCiSkip(NoteHook hook) {
|
protected boolean isCiSkip(NoteHook hook) {
|
||||||
return hook.getMergeRequest() != null
|
return hook.getPullRequest() != null
|
||||||
&& hook.getMergeRequest().getBody() != null
|
&& hook.getPullRequest().getBody() != null
|
||||||
&& hook.getMergeRequest().getBody().contains("[ci-skip]");
|
&& hook.getPullRequest().getBody().contains("[ci-skip]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +51,7 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected String getTargetBranch(NoteHook hook) {
|
protected String getTargetBranch(NoteHook hook) {
|
||||||
return hook.getMergeRequest() == null ? null : hook.getMergeRequest().getTargetBranch();
|
return hook.getPullRequest() == null ? null : hook.getPullRequest().getTargetBranch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,31 +63,31 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
||||||
protected CauseData retrieveCauseData(NoteHook hook) {
|
protected CauseData retrieveCauseData(NoteHook hook) {
|
||||||
return causeData()
|
return causeData()
|
||||||
.withActionType(CauseData.ActionType.NOTE)
|
.withActionType(CauseData.ActionType.NOTE)
|
||||||
.withSourceProjectId(hook.getMergeRequest().getSourceProjectId())
|
.withSourceProjectId(hook.getPullRequest().getSourceProjectId())
|
||||||
.withTargetProjectId(hook.getMergeRequest().getTargetProjectId())
|
.withTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
||||||
.withBranch(hook.getMergeRequest().getSourceBranch())
|
.withBranch(hook.getPullRequest().getSourceBranch())
|
||||||
.withSourceBranch(hook.getMergeRequest().getSourceBranch())
|
.withSourceBranch(hook.getPullRequest().getSourceBranch())
|
||||||
.withUserName(hook.getMergeRequest().getHead().getUser().getName())
|
.withUserName(hook.getPullRequest().getHead().getUser().getName())
|
||||||
.withUserEmail(hook.getMergeRequest().getHead().getUser().getEmail())
|
.withUserEmail(hook.getPullRequest().getHead().getUser().getEmail())
|
||||||
.withSourceRepoHomepage(hook.getMergeRequest().getSource().getHomepage())
|
.withSourceRepoHomepage(hook.getPullRequest().getSource().getHomepage())
|
||||||
.withSourceRepoName(hook.getMergeRequest().getSource().getName())
|
.withSourceRepoName(hook.getPullRequest().getSource().getName())
|
||||||
.withSourceNamespace(hook.getMergeRequest().getSource().getNamespace())
|
.withSourceNamespace(hook.getPullRequest().getSource().getNamespace())
|
||||||
.withSourceRepoUrl(hook.getMergeRequest().getSource().getUrl())
|
.withSourceRepoUrl(hook.getPullRequest().getSource().getUrl())
|
||||||
.withSourceRepoSshUrl(hook.getMergeRequest().getSource().getSshUrl())
|
.withSourceRepoSshUrl(hook.getPullRequest().getSource().getSshUrl())
|
||||||
.withSourceRepoHttpUrl(hook.getMergeRequest().getSource().getGitHttpUrl())
|
.withSourceRepoHttpUrl(hook.getPullRequest().getSource().getGitHttpUrl())
|
||||||
.withMergeRequestTitle(hook.getMergeRequest().getTitle())
|
.withPullRequestTitle(hook.getPullRequest().getTitle())
|
||||||
.withMergeRequestDescription(hook.getMergeRequest().getBody())
|
.withPullRequestDescription(hook.getPullRequest().getBody())
|
||||||
.withMergeRequestId(hook.getMergeRequest().getId())
|
.withPullRequestId(hook.getPullRequest().getId())
|
||||||
.withMergeRequestIid(hook.getMergeRequest().getNumber())
|
.withPullRequestIid(hook.getPullRequest().getNumber())
|
||||||
.withMergeRequestTargetProjectId(hook.getMergeRequest().getTargetProjectId())
|
.withPullRequestTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
||||||
.withTargetBranch(hook.getMergeRequest().getTargetBranch())
|
.withTargetBranch(hook.getPullRequest().getTargetBranch())
|
||||||
.withTargetRepoName(hook.getMergeRequest().getTarget().getName())
|
.withTargetRepoName(hook.getPullRequest().getTarget().getName())
|
||||||
.withTargetNamespace(hook.getMergeRequest().getTarget().getNamespace())
|
.withTargetNamespace(hook.getPullRequest().getTarget().getNamespace())
|
||||||
.withTargetRepoSshUrl(hook.getMergeRequest().getTarget().getSshUrl())
|
.withTargetRepoSshUrl(hook.getPullRequest().getTarget().getSshUrl())
|
||||||
.withTargetRepoHttpUrl(hook.getMergeRequest().getTarget().getGitHttpUrl())
|
.withTargetRepoHttpUrl(hook.getPullRequest().getTarget().getGitHttpUrl())
|
||||||
.withTriggeredByUser(hook.getMergeRequest().getHead().getUser().getName())
|
.withTriggeredByUser(hook.getPullRequest().getHead().getUser().getName())
|
||||||
.withLastCommit(hook.getMergeRequest().getMergeCommitSha())
|
.withLastCommit(hook.getPullRequest().getMergeCommitSha())
|
||||||
.withTargetProjectUrl(hook.getMergeRequest().getTarget().getUrl())
|
.withTargetProjectUrl(hook.getPullRequest().getTarget().getUrl())
|
||||||
.withTriggerPhrase(hook.getObjectAttributes().getNote())
|
.withTriggerPhrase(hook.getObjectAttributes().getNote())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -104,17 +100,17 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
||||||
@Override
|
@Override
|
||||||
protected BuildStatusUpdate retrieveBuildStatusUpdate(NoteHook hook) {
|
protected BuildStatusUpdate retrieveBuildStatusUpdate(NoteHook hook) {
|
||||||
return buildStatusUpdate()
|
return buildStatusUpdate()
|
||||||
.withProjectId(hook.getMergeRequest().getSourceProjectId())
|
.withProjectId(hook.getPullRequest().getSourceProjectId())
|
||||||
.withSha(hook.getMergeRequest().getMergeCommitSha())
|
.withSha(hook.getPullRequest().getMergeCommitSha())
|
||||||
.withRef(hook.getMergeRequest().getSourceBranch())
|
.withRef(hook.getPullRequest().getSourceBranch())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String retrieveRevisionToBuild(NoteHook hook) throws NoRevisionToBuildException {
|
private String retrieveRevisionToBuild(NoteHook hook) throws NoRevisionToBuildException {
|
||||||
if (hook.getMergeRequest() != null
|
if (hook.getPullRequest() != null
|
||||||
&& hook.getMergeRequest().getMergeCommitSha() != null) {
|
&& hook.getPullRequest().getMergeCommitSha() != null) {
|
||||||
|
|
||||||
return hook.getMergeRequest().getMergeCommitSha();
|
return hook.getPullRequest().getMergeCommitSha();
|
||||||
} else {
|
} else {
|
||||||
throw new NoRevisionToBuildException();
|
throw new NoRevisionToBuildException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler.pipeline;
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.PipelineHook;
|
import com.gitee.jenkins.gitee.hook.model.PipelineHook;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@ import hudson.model.Job;
|
||||||
class NopPipelineHookTriggerHandler implements PipelineHookTriggerHandler {
|
class NopPipelineHookTriggerHandler implements PipelineHookTriggerHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, PipelineHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, PipelineHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.gitee.jenkins.gitee.hook.model.PipelineEventObjectAttributes;
|
||||||
import com.gitee.jenkins.gitee.hook.model.PipelineHook;
|
import com.gitee.jenkins.gitee.hook.model.PipelineHook;
|
||||||
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||||
import com.gitee.jenkins.util.BuildUtil;
|
import com.gitee.jenkins.util.BuildUtil;
|
||||||
import com.gitee.jenkins.util.LoggerUtil;
|
import com.gitee.jenkins.util.LoggerUtil;
|
||||||
|
@ -44,7 +44,7 @@ class PipelineHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<Pipel
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, PipelineHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, PipelineHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
PipelineEventObjectAttributes objectAttributes = hook.getObjectAttributes();
|
PipelineEventObjectAttributes objectAttributes = hook.getObjectAttributes();
|
||||||
try {
|
try {
|
||||||
if (job instanceof AbstractProject<?, ?>) {
|
if (job instanceof AbstractProject<?, ?>) {
|
||||||
|
@ -109,7 +109,7 @@ class PipelineHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<Pipel
|
||||||
.withSourceNamespace(hook.getProject()==null||hook.getProject().getNamespace()==null?"":hook.getProject().getNamespace())
|
.withSourceNamespace(hook.getProject()==null||hook.getProject().getNamespace()==null?"":hook.getProject().getNamespace())
|
||||||
.withSourceRepoSshUrl(hook.getRepository()==null||hook.getRepository().getGitSshUrl()==null?"":hook.getRepository().getGitSshUrl())
|
.withSourceRepoSshUrl(hook.getRepository()==null||hook.getRepository().getGitSshUrl()==null?"":hook.getRepository().getGitSshUrl())
|
||||||
.withSourceRepoHttpUrl(hook.getRepository()==null||hook.getRepository()==null?"":hook.getRepository().getGitHttpUrl())
|
.withSourceRepoHttpUrl(hook.getRepository()==null||hook.getRepository()==null?"":hook.getRepository().getGitHttpUrl())
|
||||||
.withMergeRequestTitle("")
|
.withPullRequestTitle("")
|
||||||
.withTargetProjectId(hook.getProjectId())
|
.withTargetProjectId(hook.getProjectId())
|
||||||
.withTargetBranch(getTargetBranch(hook)==null?"":getTargetBranch(hook))
|
.withTargetBranch(getTargetBranch(hook)==null?"":getTargetBranch(hook))
|
||||||
.withTargetRepoName("")
|
.withTargetRepoName("")
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler.push;
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,7 @@ import hudson.model.Job;
|
||||||
*/
|
*/
|
||||||
class NopPushHookTriggerHandler implements PushHookTriggerHandler {
|
class NopPushHookTriggerHandler implements PushHookTriggerHandler {
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,15 @@ public final class PushHookTriggerHandlerFactory {
|
||||||
|
|
||||||
private PushHookTriggerHandlerFactory() {}
|
private PushHookTriggerHandlerFactory() {}
|
||||||
|
|
||||||
public static PushHookTriggerHandler newPushHookTriggerHandler(boolean triggerOnPush, boolean skipWorkInProgressMergeRequest) {
|
public static PushHookTriggerHandler newPushHookTriggerHandler(boolean triggerOnPush, boolean skipWorkInProgressPullRequest) {
|
||||||
if (triggerOnPush) {
|
if (triggerOnPush) {
|
||||||
return new PushHookTriggerHandlerList(retrieveHandlers(triggerOnPush, skipWorkInProgressMergeRequest));
|
return new PushHookTriggerHandlerList(retrieveHandlers(triggerOnPush, skipWorkInProgressPullRequest));
|
||||||
} else {
|
} else {
|
||||||
return new NopPushHookTriggerHandler();
|
return new NopPushHookTriggerHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<PushHookTriggerHandler> retrieveHandlers(boolean triggerOnPush, boolean skipWorkInProgressMergeRequest) {
|
private static List<PushHookTriggerHandler> retrieveHandlers(boolean triggerOnPush, boolean skipWorkInProgressPullRequest) {
|
||||||
List<PushHookTriggerHandler> result = new ArrayList<>();
|
List<PushHookTriggerHandler> result = new ArrayList<>();
|
||||||
if (triggerOnPush) {
|
if (triggerOnPush) {
|
||||||
result.add(new PushHookTriggerHandlerImpl());
|
result.add(new PushHookTriggerHandlerImpl());
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.gitee.jenkins.gitee.hook.model.Commit;
|
||||||
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
||||||
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
import com.gitee.jenkins.trigger.handler.AbstractWebHookTriggerHandler;
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
import hudson.model.Run;
|
import hudson.model.Run;
|
||||||
|
@ -31,9 +31,9 @@ class PushHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<PushHook>
|
||||||
private static final String NO_COMMIT = "0000000000000000000000000000000000000000";
|
private static final String NO_COMMIT = "0000000000000000000000000000000000000000";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
if (isNoRemoveBranchPush(hook)) {
|
if (isNoRemoveBranchPush(hook)) {
|
||||||
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,14 +78,14 @@ class PushHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<PushHook>
|
||||||
.withSourceRepoUrl(hook.getProject().getUrl())
|
.withSourceRepoUrl(hook.getProject().getUrl())
|
||||||
.withSourceRepoSshUrl(hook.getProject().getSshUrl())
|
.withSourceRepoSshUrl(hook.getProject().getSshUrl())
|
||||||
.withSourceRepoHttpUrl(hook.getProject().getGitHttpUrl())
|
.withSourceRepoHttpUrl(hook.getProject().getGitHttpUrl())
|
||||||
.withMergeRequestTitle("")
|
.withPullRequestTitle("")
|
||||||
.withMergeRequestDescription("")
|
.withPullRequestDescription("")
|
||||||
.withMergeRequestId(null)
|
.withPullRequestId(null)
|
||||||
.withMergeRequestIid(null)
|
.withPullRequestIid(null)
|
||||||
.withMergeRequestState(null)
|
.withPullRequestState(null)
|
||||||
.withMergedByUser("")
|
.withMergedByUser("")
|
||||||
.withMergeRequestAssignee("")
|
.withPullRequestAssignee("")
|
||||||
.withMergeRequestTargetProjectId(null)
|
.withPullRequestTargetProjectId(null)
|
||||||
.withTargetBranch(getTargetBranch(hook))
|
.withTargetBranch(getTargetBranch(hook))
|
||||||
.withTargetRepoName("")
|
.withTargetRepoName("")
|
||||||
.withTargetNamespace("")
|
.withTargetNamespace("")
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler.push;
|
||||||
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
||||||
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
import com.gitee.jenkins.trigger.filter.BranchFilter;
|
||||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||||
import hudson.model.Job;
|
import hudson.model.Job;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,9 +19,9 @@ class PushHookTriggerHandlerList implements PushHookTriggerHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||||
for (PushHookTriggerHandler handler : handlers) {
|
for (PushHookTriggerHandler handler : handlers) {
|
||||||
handler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
handler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.gitee.jenkins.webhook;
|
package com.gitee.jenkins.webhook;
|
||||||
|
|
||||||
import com.gitee.jenkins.util.ACLUtil;
|
import com.gitee.jenkins.util.ACLUtil;
|
||||||
import com.gitee.jenkins.webhook.build.MergeRequestBuildAction;
|
import com.gitee.jenkins.webhook.build.PullRequestBuildAction;
|
||||||
import com.gitee.jenkins.webhook.build.NoteBuildAction;
|
import com.gitee.jenkins.webhook.build.NoteBuildAction;
|
||||||
import com.gitee.jenkins.webhook.build.PipelineBuildAction;
|
import com.gitee.jenkins.webhook.build.PipelineBuildAction;
|
||||||
import com.gitee.jenkins.webhook.build.PushBuildAction;
|
import com.gitee.jenkins.webhook.build.PushBuildAction;
|
||||||
|
@ -107,7 +107,7 @@ public class ActionResolver {
|
||||||
String tokenHeader = request.getHeader("X-Gitee-Token");
|
String tokenHeader = request.getHeader("X-Gitee-Token");
|
||||||
switch (eventHeader) {
|
switch (eventHeader) {
|
||||||
case "Merge Request Hook":
|
case "Merge Request Hook":
|
||||||
return new MergeRequestBuildAction(project, getRequestBody(request), tokenHeader);
|
return new PullRequestBuildAction(project, getRequestBody(request), tokenHeader);
|
||||||
case "Push Hook":
|
case "Push Hook":
|
||||||
case "Tag Push Hook":
|
case "Tag Push Hook":
|
||||||
return new PushBuildAction(project, getRequestBody(request), tokenHeader);
|
return new PushBuildAction(project, getRequestBody(request), tokenHeader);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.gitee.jenkins.webhook.build;
|
package com.gitee.jenkins.webhook.build;
|
||||||
|
|
||||||
|
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||||
import com.gitee.jenkins.trigger.GiteePushTrigger;
|
import com.gitee.jenkins.trigger.GiteePushTrigger;
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestHook;
|
import com.gitee.jenkins.gitee.hook.model.PullRequestObjectAttributes;
|
||||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestObjectAttributes;
|
|
||||||
import com.gitee.jenkins.gitee.hook.model.Project;
|
import com.gitee.jenkins.gitee.hook.model.Project;
|
||||||
import com.gitee.jenkins.util.JsonUtil;
|
import com.gitee.jenkins.util.JsonUtil;
|
||||||
import hudson.model.Item;
|
import hudson.model.Item;
|
||||||
|
@ -19,23 +19,23 @@ import static com.gitee.jenkins.util.JsonUtil.toPrettyPrint;
|
||||||
/**
|
/**
|
||||||
* @author Robin Müller
|
* @author Robin Müller
|
||||||
*/
|
*/
|
||||||
public class MergeRequestBuildAction extends BuildWebHookAction {
|
public class PullRequestBuildAction extends BuildWebHookAction {
|
||||||
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(MergeRequestBuildAction.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(PullRequestBuildAction.class.getName());
|
||||||
private Item project;
|
private Item project;
|
||||||
private MergeRequestHook mergeRequestHook;
|
private PullRequestHook pullRequestHook;
|
||||||
private final String secretToken;
|
private final String secretToken;
|
||||||
|
|
||||||
public MergeRequestBuildAction(Item project, String json, String secretToken) {
|
public PullRequestBuildAction(Item project, String json, String secretToken) {
|
||||||
LOGGER.log(Level.FINE, "MergeRequest: {0}", toPrettyPrint(json));
|
LOGGER.log(Level.FINE, "PullRequest: {0}", toPrettyPrint(json));
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.mergeRequestHook = JsonUtil.read(json, MergeRequestHook.class);
|
this.pullRequestHook = JsonUtil.read(json, PullRequestHook.class);
|
||||||
this.secretToken = secretToken;
|
this.secretToken = secretToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
void processForCompatibility() {
|
void processForCompatibility() {
|
||||||
// url and homepage are introduced in 8.x versions of Gitee
|
// url and homepage are introduced in 8.x versions of Gitee
|
||||||
final MergeRequestObjectAttributes attributes = this.mergeRequestHook.getPullRequest();
|
final PullRequestObjectAttributes attributes = this.pullRequestHook.getPullRequest();
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
final Project source = attributes.getSource();
|
final Project source = attributes.getSource();
|
||||||
if (source != null && source.getGitHttpUrl() != null) {
|
if (source != null && source.getGitHttpUrl() != null) {
|
||||||
|
@ -47,9 +47,9 @@ public class MergeRequestBuildAction extends BuildWebHookAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The MergeRequestHookTriggerHandlerImpl is looking for Project
|
// The PullRequestHookTriggerHandlerImpl is looking for Project
|
||||||
if (mergeRequestHook.getRepo() == null && attributes.getTarget() != null) {
|
if (pullRequestHook.getRepo() == null && attributes.getTarget() != null) {
|
||||||
mergeRequestHook.setRepo(attributes.getTarget());
|
pullRequestHook.setRepo(attributes.getTarget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ public class MergeRequestBuildAction extends BuildWebHookAction {
|
||||||
ACL.impersonate(ACL.SYSTEM, new TriggerNotifier(project, secretToken, Jenkins.getAuthentication()) {
|
ACL.impersonate(ACL.SYSTEM, new TriggerNotifier(project, secretToken, Jenkins.getAuthentication()) {
|
||||||
@Override
|
@Override
|
||||||
protected void performOnPost(GiteePushTrigger trigger) {
|
protected void performOnPost(GiteePushTrigger trigger) {
|
||||||
trigger.onPost(mergeRequestHook);
|
trigger.onPost(pullRequestHook);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
throw responseWithHook(mergeRequestHook);
|
throw responseWithHook(pullRequestHook);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ import org.kohsuke.stapler.export.ExportedBean;
|
||||||
|
|
||||||
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
||||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import hudson.Extension;
|
import hudson.Extension;
|
||||||
|
@ -29,20 +29,20 @@ import hudson.model.TaskListener;
|
||||||
* @author <a href="mailto:robin.mueller@1und1.de">Robin Müller</a>
|
* @author <a href="mailto:robin.mueller@1und1.de">Robin Müller</a>
|
||||||
*/
|
*/
|
||||||
@ExportedBean
|
@ExportedBean
|
||||||
public class AcceptGiteeMergeRequestStep extends Step {
|
public class AcceptGiteePullRequestStep extends Step {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(AcceptGiteeMergeRequestStep.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(AcceptGiteePullRequestStep.class.getName());
|
||||||
|
|
||||||
private String mergeCommitMessage;
|
private String mergeCommitMessage;
|
||||||
|
|
||||||
@DataBoundConstructor
|
@DataBoundConstructor
|
||||||
public AcceptGiteeMergeRequestStep(String mergeCommitMessage) {
|
public AcceptGiteePullRequestStep(String mergeCommitMessage) {
|
||||||
this.mergeCommitMessage = StringUtils.isEmpty(mergeCommitMessage) ? null : mergeCommitMessage;
|
this.mergeCommitMessage = StringUtils.isEmpty(mergeCommitMessage) ? null : mergeCommitMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StepExecution start(StepContext context) throws Exception {
|
public StepExecution start(StepContext context) throws Exception {
|
||||||
return new AcceptGiteeMergeRequestStepExecution(context, this);
|
return new AcceptGiteePullRequestStepExecution(context, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMergeCommitMessage() {
|
public String getMergeCommitMessage() {
|
||||||
|
@ -54,14 +54,14 @@ public class AcceptGiteeMergeRequestStep extends Step {
|
||||||
this.mergeCommitMessage = StringUtils.isEmpty(mergeCommitMessage) ? null : mergeCommitMessage;
|
this.mergeCommitMessage = StringUtils.isEmpty(mergeCommitMessage) ? null : mergeCommitMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AcceptGiteeMergeRequestStepExecution extends AbstractSynchronousStepExecution<Void> {
|
public static class AcceptGiteePullRequestStepExecution extends AbstractSynchronousStepExecution<Void> {
|
||||||
private static final long serialVersionUID = 1;
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
private final transient Run<?, ?> run;
|
private final transient Run<?, ?> run;
|
||||||
|
|
||||||
private final transient AcceptGiteeMergeRequestStep step;
|
private final transient AcceptGiteePullRequestStep step;
|
||||||
|
|
||||||
AcceptGiteeMergeRequestStepExecution(StepContext context, AcceptGiteeMergeRequestStep step) throws Exception {
|
AcceptGiteePullRequestStepExecution(StepContext context, AcceptGiteePullRequestStep step) throws Exception {
|
||||||
super(context);
|
super(context);
|
||||||
this.step = step;
|
this.step = step;
|
||||||
run = context.get(Run.class);
|
run = context.get(Run.class);
|
||||||
|
@ -71,17 +71,17 @@ public class AcceptGiteeMergeRequestStep extends Step {
|
||||||
protected Void run() throws Exception {
|
protected Void run() throws Exception {
|
||||||
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
MergeRequest mergeRequest = cause.getData().getMergeRequest();
|
PullRequest pullRequest = cause.getData().getPullRequest();
|
||||||
if (mergeRequest != null) {
|
if (pullRequest != null) {
|
||||||
GiteeClient client = getClient(run);
|
GiteeClient client = getClient(run);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
println("No Gitee connection configured");
|
println("No Gitee connection configured");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
client.acceptMergeRequest(mergeRequest, step.mergeCommitMessage, false);
|
client.acceptPullRequest(pullRequest, step.mergeCommitMessage, false);
|
||||||
} catch (WebApplicationException | ProcessingException e) {
|
} catch (WebApplicationException | ProcessingException e) {
|
||||||
printf("Failed to accept merge request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
printf("Failed to accept pull request for project '%s': %s%n", pullRequest.getProjectId(), e.getMessage());
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to accept merge request for project '%s'", mergeRequest.getProjectId()), e);
|
LOGGER.log(Level.SEVERE, String.format("Failed to accept pull request for project '%s'", pullRequest.getProjectId()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ import java.util.logging.Logger;
|
||||||
import javax.ws.rs.ProcessingException;
|
import javax.ws.rs.ProcessingException;
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
|
||||||
|
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution;
|
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution;
|
||||||
import org.jenkinsci.plugins.workflow.steps.Step;
|
import org.jenkinsci.plugins.workflow.steps.Step;
|
||||||
|
@ -21,7 +22,6 @@ import org.kohsuke.stapler.export.ExportedBean;
|
||||||
|
|
||||||
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
||||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import hudson.Extension;
|
import hudson.Extension;
|
||||||
|
@ -32,20 +32,20 @@ import hudson.model.TaskListener;
|
||||||
* @author <a href="mailto:robin.mueller@1und1.de">Robin Müller</a>
|
* @author <a href="mailto:robin.mueller@1und1.de">Robin Müller</a>
|
||||||
*/
|
*/
|
||||||
@ExportedBean
|
@ExportedBean
|
||||||
public class AddGiteeMergeRequestCommentStep extends Step {
|
public class AddGiteePullRequestCommentStep extends Step {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(AddGiteeMergeRequestCommentStep.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(AddGiteePullRequestCommentStep.class.getName());
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
@DataBoundConstructor
|
@DataBoundConstructor
|
||||||
public AddGiteeMergeRequestCommentStep(String comment) {
|
public AddGiteePullRequestCommentStep(String comment) {
|
||||||
this.comment = StringUtils.isEmpty(comment) ? null : comment;
|
this.comment = StringUtils.isEmpty(comment) ? null : comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StepExecution start(StepContext context) throws Exception {
|
public StepExecution start(StepContext context) throws Exception {
|
||||||
return new AddGiteeMergeRequestCommentStepExecution(context, this);
|
return new AddGiteePullRequestCommentStepExecution(context, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getComment() {
|
public String getComment() {
|
||||||
|
@ -57,14 +57,14 @@ public class AddGiteeMergeRequestCommentStep extends Step {
|
||||||
this.comment = StringUtils.isEmpty(comment) ? null : comment;
|
this.comment = StringUtils.isEmpty(comment) ? null : comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AddGiteeMergeRequestCommentStepExecution extends AbstractSynchronousStepExecution<Void> {
|
public static class AddGiteePullRequestCommentStepExecution extends AbstractSynchronousStepExecution<Void> {
|
||||||
private static final long serialVersionUID = 1;
|
private static final long serialVersionUID = 1;
|
||||||
|
|
||||||
private final transient Run<?, ?> run;
|
private final transient Run<?, ?> run;
|
||||||
|
|
||||||
private final transient AddGiteeMergeRequestCommentStep step;
|
private final transient AddGiteePullRequestCommentStep step;
|
||||||
|
|
||||||
AddGiteeMergeRequestCommentStepExecution(StepContext context, AddGiteeMergeRequestCommentStep step) throws Exception {
|
AddGiteePullRequestCommentStepExecution(StepContext context, AddGiteePullRequestCommentStep step) throws Exception {
|
||||||
super(context);
|
super(context);
|
||||||
this.step = step;
|
this.step = step;
|
||||||
run = context.get(Run.class);
|
run = context.get(Run.class);
|
||||||
|
@ -74,17 +74,17 @@ public class AddGiteeMergeRequestCommentStep extends Step {
|
||||||
protected Void run() throws Exception {
|
protected Void run() throws Exception {
|
||||||
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
MergeRequest mergeRequest = cause.getData().getMergeRequest();
|
PullRequest pullRequest = cause.getData().getPullRequest();
|
||||||
if (mergeRequest != null) {
|
if (pullRequest != null) {
|
||||||
GiteeClient client = getClient(run);
|
GiteeClient client = getClient(run);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
println("No Gitee connection configured");
|
println("No Gitee connection configured");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
client.createMergeRequestNote(mergeRequest, step.getComment());
|
client.createPullRequestNote(pullRequest, step.getComment());
|
||||||
} catch (WebApplicationException | ProcessingException e) {
|
} catch (WebApplicationException | ProcessingException e) {
|
||||||
printf("Failed to add comment on Merge Request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
printf("Failed to add comment on Merge Request for project '%s': %s%n", pullRequest.getProjectId(), e.getMessage());
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to add comment on Merge Request for project '%s'", mergeRequest.getProjectId()), e);
|
LOGGER.log(Level.SEVERE, String.format("Failed to add comment on Merge Request for project '%s'", pullRequest.getProjectId()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
GiteeWebHookCause.ShortDescription.PushHook_noUser=Started by Gitee push
|
GiteeWebHookCause.ShortDescription.PushHook_noUser=Started by Gitee push
|
||||||
GiteeWebHookCause.ShortDescription.PushHook=Started by Gitee push by {0}
|
GiteeWebHookCause.ShortDescription.PushHook=Started by Gitee push by {0}
|
||||||
GiteeWebHookCause.ShortDescription.MergeRequestHook_html=Triggered by <a href="{3}/pulls/{0}" target="_blank">Gitee Pull Request #{0}</a>: {1} => {2}
|
GiteeWebHookCause.ShortDescription.PullRequestHook_html=Triggered by <a href="{3}/pulls/{0}" target="_blank">Gitee Pull Request #{0}</a>: {1} => {2}
|
||||||
GiteeWebHookCause.ShortDescription.MergeRequestHook_plain=Triggered by Gitee Pull Request #{0}: {1} => {2}
|
GiteeWebHookCause.ShortDescription.PullRequestHook_plain=Triggered by Gitee Pull Request #{0}: {1} => {2}
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_html=Triggered by {0} <a href="{4}/merge_requests/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3}
|
GiteeWebHookCause.ShortDescription.NoteHook_html=Triggered by {0} <a href="{4}/merge_requests/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3}
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_plain=Triggered by {0} Gitee Pull Request #{1}: {2} => {3}
|
GiteeWebHookCause.ShortDescription.NoteHook_plain=Triggered by {0} Gitee Pull Request #{1}: {2} => {3}
|
||||||
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=Started by Gitee Pipeline event
|
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=Started by Gitee Pipeline event
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
GiteeWebHookCause.ShortDescription.PushHook_noUser=Gitee \u63A8\u9001\u89E6\u53D1\u6784\u5EFA
|
GiteeWebHookCause.ShortDescription.PushHook_noUser=Gitee \u63A8\u9001\u89E6\u53D1\u6784\u5EFA
|
||||||
GiteeWebHookCause.ShortDescription.PushHook=Gitee \u7528\u6237 {0} \u63A8\u9001\u89E6\u53D1\u6784\u5EFA
|
GiteeWebHookCause.ShortDescription.PushHook=Gitee \u7528\u6237 {0} \u63A8\u9001\u89E6\u53D1\u6784\u5EFA
|
||||||
GiteeWebHookCause.ShortDescription.MergeRequestHook_html=\u7531 <a href="{3}/pulls/{0}" target="_blank">Gitee Pull Request #{0}</a>: {1} => {2} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.PullRequestHook_html=\u7531 <a href="{3}/pulls/{0}" target="_blank">Gitee Pull Request #{0}</a>: {1} => {2} \u89E6\u53D1
|
||||||
GiteeWebHookCause.ShortDescription.MergeRequestHook_plain=\u7531 Gitee Pull Request #{0}: {1} => {2} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.PullRequestHook_plain=\u7531 Gitee Pull Request #{0}: {1} => {2} \u89E6\u53D1
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_html=\u7531 {0} <a href="{4}/merge_requests/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.NoteHook_html=\u7531 {0} <a href="{4}/merge_requests/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3} \u89E6\u53D1
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_plain=\u7531 {0} Gitee Pull Request #{1}: {2} => {3} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.NoteHook_plain=\u7531 {0} Gitee Pull Request #{1}: {2} => {3} \u89E6\u53D1
|
||||||
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=\u7531 Gitee Pipeline \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=\u7531 Gitee Pipeline \u89E6\u53D1
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
GiteeCommitStatusPublisher.DisplayName=Publish build status to Gitee
|
GiteeCommitStatusPublisher.DisplayName=Publish build status to Gitee
|
||||||
name.required=Build name required.
|
name.required=Build name required.
|
||||||
GiteeMessagePublisher.DisplayName=Add note with build status on Gitee pull requests
|
GiteeMessagePublisher.DisplayName=Add note with build status on Gitee pull requests
|
||||||
GiteeAcceptMergeRequestPublisher.DisplayName=Accept Gitee pull request on success
|
GiteeAcceptPullRequestPublisher.DisplayName=Accept Gitee pull request on success
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
GiteeCommitStatusPublisher.DisplayName=\u53D1\u5E03\u6784\u5EFA\u72B6\u6001\u5230 Gitee
|
GiteeCommitStatusPublisher.DisplayName=\u53D1\u5E03\u6784\u5EFA\u72B6\u6001\u5230 Gitee
|
||||||
name.required=\u8BF7\u8F93\u5165\u6784\u5EFA\u540D\u79F0\u3002
|
name.required=\u8BF7\u8F93\u5165\u6784\u5EFA\u540D\u79F0\u3002
|
||||||
GiteeMessagePublisher.DisplayName=\u5C06\u6784\u5EFA\u72B6\u6001\u8BC4\u8BBA\u5230 Gitee Pull Request \u4E2D
|
GiteeMessagePublisher.DisplayName=\u5C06\u6784\u5EFA\u72B6\u6001\u8BC4\u8BBA\u5230 Gitee Pull Request \u4E2D
|
||||||
GiteeAcceptMergeRequestPublisher.DisplayName=\u5F53\u6784\u5EFA\u6210\u529F\u81EA\u52A8\u5408\u5E76 Gitee \u7684 Pull Request
|
GiteeAcceptPullRequestPublisher.DisplayName=\u5F53\u6784\u5EFA\u6210\u529F\u81EA\u52A8\u5408\u5E76 Gitee \u7684 Pull Request
|
||||||
|
|
|
@ -6,22 +6,22 @@
|
||||||
<f:entry title="${%Push}" field="triggerOnPush">
|
<f:entry title="${%Push}" field="triggerOnPush">
|
||||||
<f:checkbox default="true"/>
|
<f:checkbox default="true"/>
|
||||||
</f:entry>
|
</f:entry>
|
||||||
<f:entry title="${%Opened.Pull.Request}" field="triggerOnOpenMergeRequest">
|
<f:entry title="${%Opened.Pull.Request}" field="triggerOnOpenPullRequest">
|
||||||
<f:checkbox default="true"/>
|
<f:checkbox default="true"/>
|
||||||
</f:entry>
|
</f:entry>
|
||||||
<f:entry title="${%Updated.Pull.Request}" field="triggerOnUpdateMergeRequest">
|
<f:entry title="${%Updated.Pull.Request}" field="triggerOnUpdatePullRequest">
|
||||||
<f:checkbox default="true"/>
|
<f:checkbox default="true"/>
|
||||||
</f:entry>
|
</f:entry>
|
||||||
<f:entry title="${%Accepted.Pull.Request}" field="triggerOnAcceptedMergeRequest">
|
<f:entry title="${%Accepted.Pull.Request}" field="triggerOnAcceptedPullRequest">
|
||||||
<f:checkbox default="false"/>
|
<f:checkbox default="false"/>
|
||||||
</f:entry>
|
</f:entry>
|
||||||
<f:entry title="${%Closed.Pull.Request}" field="triggerOnClosedMergeRequest">
|
<f:entry title="${%Closed.Pull.Request}" field="triggerOnClosedPullRequest">
|
||||||
<f:checkbox default="false"/>
|
<f:checkbox default="false"/>
|
||||||
</f:entry>
|
</f:entry>
|
||||||
<f:entry title="${%Approved.Pull.Request}" field="triggerOnApprovedMergeRequest">
|
<f:entry title="${%Approved.Pull.Request}" field="triggerOnApprovedPullRequest">
|
||||||
<f:checkbox default="false"/>
|
<f:checkbox default="false"/>
|
||||||
</f:entry>
|
</f:entry>
|
||||||
<f:entry title="${%Tested.Pull.Request}" field="triggerOnTestedMergeRequest">
|
<f:entry title="${%Tested.Pull.Request}" field="triggerOnTestedPullRequest">
|
||||||
<f:checkbox default="false"/>
|
<f:checkbox default="false"/>
|
||||||
</f:entry>
|
</f:entry>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -28,7 +28,7 @@ Allow.all.branches=Allow all branches to trigger this job
|
||||||
Filter.branches.by.name=Filter branches by name
|
Filter.branches.by.name=Filter branches by name
|
||||||
Filter.branches.by.regex=Filter branches by regex
|
Filter.branches.by.regex=Filter branches by regex
|
||||||
Target.Branch.Regex=Target Branch Regex
|
Target.Branch.Regex=Target Branch Regex
|
||||||
Filter.merge.request.by.label=Filter merge request by label
|
Filter.merge.request.by.label=Filter pull request by label
|
||||||
Exclude=Exclude
|
Exclude=Exclude
|
||||||
Include=Include
|
Include=Include
|
||||||
Ignore.Last.Commit.Has.Build=Ignore last commit has been build
|
Ignore.Last.Commit.Has.Build=Ignore last commit has been build
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
This plugin integrates
|
This plugin integrates
|
||||||
<a href="http://gitee.com/">Gitee</a>
|
<a href="http://gitee.com/">Gitee</a>
|
||||||
to Jenkins by faking a Gitee CI Server.
|
to Jenkins by faking a Gitee CI Server.
|
||||||
This plugin allows Gitee to trigger builds in Jenkins when code is committed or merge requests are opened/updated.
|
This plugin allows Gitee to trigger builds in Jenkins when code is committed or pull requests are opened/updated.
|
||||||
It can also send build status back to Gitee.
|
It can also send build status back to Gitee.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<p>When filled, a comment in the merge request matching this regular expression will trigger a build.</p>
|
<p>When filled, a comment in the pull request matching this regular expression will trigger a build.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<div>
|
<div>
|
||||||
Send build result to Gitee. It will be visible in the commit and/or merge request UI as appropriate. You must have at least one Gitee connection/server configured in the Jenkins global configuration. If you have more than one, select the appropriate one from the 'Gitee connection' dropdown menu in the job configuration.
|
Send build result to Gitee. It will be visible in the commit and/or pull request UI as appropriate. You must have at least one Gitee connection/server configured in the Jenkins global configuration. If you have more than one, select the appropriate one from the 'Gitee connection' dropdown menu in the job configuration.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div>
|
<div>
|
||||||
Send build result to Gitee.
|
Send build result to Gitee.
|
||||||
It will be visible in the commit and/or merge request UI as appropriate.
|
It will be visible in the commit and/or pull request UI as appropriate.
|
||||||
You must have at least one Gitee connection/server configured in the Jenkins global configuration.
|
You must have at least one Gitee connection/server configured in the Jenkins global configuration.
|
||||||
If you have more than one, select the appropriate one from the 'Gitee connection' dropdown menu in the job configuration.
|
If you have more than one, select the appropriate one from the 'Gitee connection' dropdown menu in the job configuration.
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue