不可自动合并的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)
|
||||
- [Advanced features](#advanced-features)
|
||||
- [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)
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -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*
|
||||
* 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*
|
||||
* 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
|
||||
2. Configure any other pre build, build or post build actions as necessary
|
||||
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
|
||||
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 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.
|
||||
|
||||
|
||||
## Add a note to merge 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.
|
||||
## Add a note to pull requests
|
||||
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
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -16,7 +16,7 @@
|
|||
<artifactId>gitee</artifactId>
|
||||
<version>1.0.12-SNAPSHOT</version>
|
||||
<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>
|
||||
<packaging>hpi</packaging>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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 jenkins.model.Jenkins;
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
|
@ -31,14 +31,14 @@ public final class CauseData {
|
|||
private final String sourceRepoUrl;
|
||||
private final String sourceRepoSshUrl;
|
||||
private final String sourceRepoHttpUrl;
|
||||
private final String mergeRequestTitle;
|
||||
private final String mergeRequestDescription;
|
||||
private final Integer mergeRequestId;
|
||||
private final Integer mergeRequestIid;
|
||||
private final String mergeRequestState;
|
||||
private final String pullRequestTitle;
|
||||
private final String pullRequestDescription;
|
||||
private final Integer pullRequestId;
|
||||
private final Integer pullRequestIid;
|
||||
private final String pullRequestState;
|
||||
private final String mergedByUser;
|
||||
private final String mergeRequestAssignee;
|
||||
private final Integer mergeRequestTargetProjectId;
|
||||
private final String pullRequestAssignee;
|
||||
private final Integer pullRequestTargetProjectId;
|
||||
private final String targetBranch;
|
||||
private final String targetRepoName;
|
||||
private final String targetNamespace;
|
||||
|
@ -63,10 +63,10 @@ public final class CauseData {
|
|||
@GeneratePojoBuilder(withFactoryMethod = "*")
|
||||
CauseData(ActionType actionType, Integer sourceProjectId, Integer targetProjectId, String branch, String sourceBranch, String userName,
|
||||
String userEmail, String sourceRepoHomepage, String sourceRepoName, String sourceNamespace, String sourceRepoUrl,
|
||||
String sourceRepoSshUrl, String sourceRepoHttpUrl, String mergeRequestTitle, String mergeRequestDescription, Integer mergeRequestId,
|
||||
Integer mergeRequestIid, Integer mergeRequestTargetProjectId, String targetBranch, String targetRepoName, String targetNamespace, String targetRepoSshUrl,
|
||||
String sourceRepoSshUrl, String sourceRepoHttpUrl, String pullRequestTitle, String pullRequestDescription, Integer pullRequestId,
|
||||
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 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) {
|
||||
this.actionType = checkNotNull(actionType, "actionType 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.sourceRepoSshUrl = checkNotNull(sourceRepoSshUrl, "sourceRepoSshUrl must not be null.");
|
||||
this.sourceRepoHttpUrl = checkNotNull(sourceRepoHttpUrl, "sourceRepoHttpUrl must not be null.");
|
||||
this.mergeRequestTitle = checkNotNull(mergeRequestTitle, "mergeRequestTitle must not be null.");
|
||||
this.mergeRequestDescription = mergeRequestDescription == null ? "" : mergeRequestDescription;
|
||||
this.mergeRequestId = mergeRequestId;
|
||||
this.mergeRequestIid = mergeRequestIid;
|
||||
this.mergeRequestState = mergeRequestState == null ? "" : mergeRequestState;
|
||||
this.pullRequestTitle = checkNotNull(pullRequestTitle, "pullRequestTitle must not be null.");
|
||||
this.pullRequestDescription = pullRequestDescription == null ? "" : pullRequestDescription;
|
||||
this.pullRequestId = pullRequestId;
|
||||
this.pullRequestIid = pullRequestIid;
|
||||
this.pullRequestState = pullRequestState == null ? "" : pullRequestState;
|
||||
this.mergedByUser = mergedByUser == null ? "" : mergedByUser;
|
||||
this.mergeRequestAssignee = mergeRequestAssignee == null ? "" : mergeRequestAssignee;
|
||||
this.mergeRequestTargetProjectId = mergeRequestTargetProjectId;
|
||||
this.pullRequestAssignee = pullRequestAssignee == null ? "" : pullRequestAssignee;
|
||||
this.pullRequestTargetProjectId = pullRequestTargetProjectId;
|
||||
this.targetBranch = checkNotNull(targetBranch, "targetBranch must not be null.");
|
||||
this.targetRepoName = checkNotNull(targetRepoName, "targetRepoName 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.before = before == null ? "" : before;
|
||||
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.triggerPhrase = triggerPhrase;
|
||||
this.ref = ref;
|
||||
|
@ -125,15 +127,15 @@ public final class CauseData {
|
|||
variables.put("giteeSourceRepoURL", sourceRepoUrl);
|
||||
variables.put("giteeSourceRepoSshUrl", sourceRepoSshUrl);
|
||||
variables.put("giteeSourceRepoHttpUrl", sourceRepoHttpUrl);
|
||||
variables.put("giteeMergeRequestTitle", mergeRequestTitle);
|
||||
variables.put("giteeMergeRequestDescription", mergeRequestDescription);
|
||||
variables.put("giteeMergeRequestId", mergeRequestId == null ? "" : mergeRequestId.toString());
|
||||
variables.put("giteeMergeRequestIid", mergeRequestIid == null ? "" : mergeRequestIid.toString());
|
||||
variables.put("giteeMergeRequestTargetProjectId", mergeRequestTargetProjectId == null ? "" : mergeRequestTargetProjectId.toString());
|
||||
variables.put("giteeMergeRequestLastCommit", lastCommit);
|
||||
variables.putIfNotNull("giteeMergeRequestState", mergeRequestState);
|
||||
variables.put("giteePullRequestTitle", pullRequestTitle);
|
||||
variables.put("giteePullRequestDescription", pullRequestDescription);
|
||||
variables.put("giteePullRequestId", pullRequestId == null ? "" : pullRequestId.toString());
|
||||
variables.put("giteePullRequestIid", pullRequestIid == null ? "" : pullRequestIid.toString());
|
||||
variables.put("giteePullRequestTargetProjectId", pullRequestTargetProjectId == null ? "" : pullRequestTargetProjectId.toString());
|
||||
variables.put("giteePullRequestLastCommit", lastCommit);
|
||||
variables.putIfNotNull("giteePullRequestState", pullRequestState);
|
||||
variables.putIfNotNull("giteeMergedByUser", mergedByUser);
|
||||
variables.putIfNotNull("giteeMergeRequestAssignee", mergeRequestAssignee);
|
||||
variables.putIfNotNull("giteePullRequestAssignee", pullRequestAssignee);
|
||||
variables.put("giteeTargetBranch", targetBranch);
|
||||
variables.put("giteeTargetRepoName", targetRepoName);
|
||||
variables.put("giteeTargetNamespace", targetNamespace);
|
||||
|
@ -206,26 +208,26 @@ public final class CauseData {
|
|||
return sourceRepoHttpUrl;
|
||||
}
|
||||
|
||||
public String getMergeRequestTitle() {
|
||||
return mergeRequestTitle;
|
||||
public String getPullRequestTitle() {
|
||||
return pullRequestTitle;
|
||||
}
|
||||
|
||||
public String getMergeRequestDescription() {
|
||||
return mergeRequestDescription;
|
||||
public String getPullRequestDescription() {
|
||||
return pullRequestDescription;
|
||||
}
|
||||
|
||||
public String getPathWithNamespace() { return pathWithNamespace; }
|
||||
|
||||
public Integer getMergeRequestId() {
|
||||
return mergeRequestId;
|
||||
public Integer getPullRequestId() {
|
||||
return pullRequestId;
|
||||
}
|
||||
|
||||
public Integer getMergeRequestIid() {
|
||||
return mergeRequestIid;
|
||||
public Integer getPullRequestIid() {
|
||||
return pullRequestIid;
|
||||
}
|
||||
|
||||
public Integer getMergeRequestTargetProjectId() {
|
||||
return mergeRequestTargetProjectId;
|
||||
public Integer getPullRequestTargetProjectId() {
|
||||
return pullRequestTargetProjectId;
|
||||
}
|
||||
|
||||
public String getTargetBranch() {
|
||||
|
@ -291,25 +293,25 @@ public final class CauseData {
|
|||
return actionType.getShortDescription(this);
|
||||
}
|
||||
|
||||
public String getMergeRequestState() {
|
||||
return mergeRequestState;
|
||||
public String getPullRequestState() {
|
||||
return pullRequestState;
|
||||
}
|
||||
|
||||
public String getMergedByUser() {
|
||||
return mergedByUser;
|
||||
}
|
||||
|
||||
public String getMergeRequestAssignee() {
|
||||
return mergeRequestAssignee;
|
||||
public String getPullRequestAssignee() {
|
||||
return pullRequestAssignee;
|
||||
}
|
||||
|
||||
public MergeRequest getMergeRequest() {
|
||||
if (mergeRequestId == null) {
|
||||
public PullRequest getPullRequest() {
|
||||
if (pullRequestId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new MergeRequest(mergeRequestId, mergeRequestIid, sourceBranch, targetBranch, mergeRequestTitle,
|
||||
sourceProjectId, targetProjectId, mergeRequestDescription, mergeRequestState, pathWithNamespace);
|
||||
return new PullRequest(pullRequestId, pullRequestIid, sourceBranch, targetBranch, pullRequestTitle,
|
||||
sourceProjectId, targetProjectId, pullRequestDescription, pullRequestState, pathWithNamespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -335,14 +337,14 @@ public final class CauseData {
|
|||
.append(sourceRepoUrl, causeData.sourceRepoUrl)
|
||||
.append(sourceRepoSshUrl, causeData.sourceRepoSshUrl)
|
||||
.append(sourceRepoHttpUrl, causeData.sourceRepoHttpUrl)
|
||||
.append(mergeRequestTitle, causeData.mergeRequestTitle)
|
||||
.append(mergeRequestDescription, causeData.mergeRequestDescription)
|
||||
.append(mergeRequestId, causeData.mergeRequestId)
|
||||
.append(mergeRequestIid, causeData.mergeRequestIid)
|
||||
.append(mergeRequestState, causeData.mergeRequestState)
|
||||
.append(pullRequestTitle, causeData.pullRequestTitle)
|
||||
.append(pullRequestDescription, causeData.pullRequestDescription)
|
||||
.append(pullRequestId, causeData.pullRequestId)
|
||||
.append(pullRequestIid, causeData.pullRequestIid)
|
||||
.append(pullRequestState, causeData.pullRequestState)
|
||||
.append(mergedByUser, causeData.mergedByUser)
|
||||
.append(mergeRequestAssignee, causeData.mergeRequestAssignee)
|
||||
.append(mergeRequestTargetProjectId, causeData.mergeRequestTargetProjectId)
|
||||
.append(pullRequestAssignee, causeData.pullRequestAssignee)
|
||||
.append(pullRequestTargetProjectId, causeData.pullRequestTargetProjectId)
|
||||
.append(targetBranch, causeData.targetBranch)
|
||||
.append(targetRepoName, causeData.targetRepoName)
|
||||
.append(targetNamespace, causeData.targetNamespace)
|
||||
|
@ -382,14 +384,14 @@ public final class CauseData {
|
|||
.append(sourceRepoUrl)
|
||||
.append(sourceRepoSshUrl)
|
||||
.append(sourceRepoHttpUrl)
|
||||
.append(mergeRequestTitle)
|
||||
.append(mergeRequestDescription)
|
||||
.append(mergeRequestId)
|
||||
.append(mergeRequestIid)
|
||||
.append(mergeRequestState)
|
||||
.append(pullRequestTitle)
|
||||
.append(pullRequestDescription)
|
||||
.append(pullRequestId)
|
||||
.append(pullRequestIid)
|
||||
.append(pullRequestState)
|
||||
.append(mergedByUser)
|
||||
.append(mergeRequestAssignee)
|
||||
.append(mergeRequestTargetProjectId)
|
||||
.append(pullRequestAssignee)
|
||||
.append(pullRequestTargetProjectId)
|
||||
.append(targetBranch)
|
||||
.append(targetRepoName)
|
||||
.append(targetNamespace)
|
||||
|
@ -429,14 +431,14 @@ public final class CauseData {
|
|||
.append("sourceRepoUrl", sourceRepoUrl)
|
||||
.append("sourceRepoSshUrl", sourceRepoSshUrl)
|
||||
.append("sourceRepoHttpUrl", sourceRepoHttpUrl)
|
||||
.append("mergeRequestTitle", mergeRequestTitle)
|
||||
.append("mergeRequestDescription", mergeRequestDescription)
|
||||
.append("mergeRequestId", mergeRequestId)
|
||||
.append("mergeRequestIid", mergeRequestIid)
|
||||
.append("mergeRequestState", mergeRequestState)
|
||||
.append("pullRequestTitle", pullRequestTitle)
|
||||
.append("pullRequestDescription", pullRequestDescription)
|
||||
.append("pullRequestId", pullRequestId)
|
||||
.append("pullRequestIid", pullRequestIid)
|
||||
.append("pullRequestState", pullRequestState)
|
||||
.append("mergedByUser", mergedByUser)
|
||||
.append("mergeRequestAssignee", mergeRequestAssignee)
|
||||
.append("mergeRequestTargetProjectId", mergeRequestTargetProjectId)
|
||||
.append("pullRequestAssignee", pullRequestAssignee)
|
||||
.append("pullRequestTargetProjectId", pullRequestTargetProjectId)
|
||||
.append("targetBranch", targetBranch)
|
||||
.append("targetRepoName", targetRepoName)
|
||||
.append("targetNamespace", targetNamespace)
|
||||
|
@ -476,11 +478,11 @@ public final class CauseData {
|
|||
String getShortDescription(CauseData data) {
|
||||
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch()) ? "" : data.getSourceNamespace() + "/";
|
||||
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(),
|
||||
data.getTargetBranch());
|
||||
} else {
|
||||
return Messages.GiteeWebHookCause_ShortDescription_MergeRequestHook_html(String.valueOf(data.getMergeRequestIid()),
|
||||
return Messages.GiteeWebHookCause_ShortDescription_PullRequestHook_html(String.valueOf(data.getPullRequestIid()),
|
||||
forkNamespace + data.getSourceBranch(),
|
||||
data.getTargetBranch(),
|
||||
data.getTargetProjectUrl());
|
||||
|
@ -493,12 +495,12 @@ public final class CauseData {
|
|||
String forkNamespace = StringUtils.equals(data.getSourceNamespace(), data.getTargetBranch()) ? "" : data.getSourceNamespace() + "/";
|
||||
if (Jenkins.getActiveInstance().getMarkupFormatter() instanceof EscapedMarkupFormatter || data.getTargetProjectUrl() == null) {
|
||||
return Messages.GiteeWebHookCause_ShortDescription_NoteHook_plain(triggeredBy,
|
||||
String.valueOf(data.getMergeRequestIid()),
|
||||
String.valueOf(data.getPullRequestIid()),
|
||||
forkNamespace + data.getSourceBranch(),
|
||||
data.getTargetBranch());
|
||||
} else {
|
||||
return Messages.GiteeWebHookCause_ShortDescription_NoteHook_html(triggeredBy,
|
||||
String.valueOf(data.getMergeRequestIid()),
|
||||
String.valueOf(data.getPullRequestIid()),
|
||||
forkNamespace + data.getSourceBranch(),
|
||||
data.getTargetBranch(),
|
||||
data.getTargetProjectUrl());
|
||||
|
|
|
@ -47,6 +47,15 @@ public class GiteeConnectionProperty extends JobProperty<Job<?, ?>> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static GiteeClient getClient(Job<?, ?> job) {
|
||||
final GiteeConnectionProperty connectionProperty = job.getProperty(GiteeConnectionProperty.class);
|
||||
if (connectionProperty != null) {
|
||||
return connectionProperty.getClient();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Extension
|
||||
@Symbol("giteeConnection")
|
||||
public static class DescriptorImpl extends JobPropertyDescriptor {
|
||||
|
|
|
@ -5,9 +5,9 @@ import com.gitee.jenkins.gitee.api.model.*;
|
|||
public interface GiteeClient {
|
||||
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();
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import com.gitee.jenkins.gitee.api.model.*;
|
|||
|
||||
|
||||
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 acceptMergeRequest(String owner, String repo, Integer mergeRequestId);
|
||||
void acceptPullRequest(String owner, String repo, Integer pullRequestId);
|
||||
User getCurrentUser();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ interface GiteeV5ApiProxy extends GiteeApiProxy {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
@Path("/repos/{ownerPath}/{repoPath}/pulls/{prNumber}/merge")
|
||||
void acceptMergeRequest(@PathParam("ownerPath") String ownerPath,
|
||||
void acceptPullRequest(@PathParam("ownerPath") String ownerPath,
|
||||
@PathParam("repoPath") String repoPath,
|
||||
@PathParam("prNumber") Integer prNumber);
|
||||
|
||||
|
@ -25,7 +25,7 @@ interface GiteeV5ApiProxy extends GiteeApiProxy {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
@Path("/repos/{ownerPath}/{repoPath}/pulls/{prNumber}/comments")
|
||||
void createMergeRequestNote(@PathParam("ownerPath") String ownerPath,
|
||||
void createPullRequestNote(@PathParam("ownerPath") String ownerPath,
|
||||
@PathParam("repoPath") String repoPath,
|
||||
@PathParam("prNumber") Integer prNumber,
|
||||
@FormParam("body") String body);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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 hudson.Extension;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
|
@ -12,10 +12,10 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
|
|||
@Restricted(NoExternalUse.class)
|
||||
public final class GiteeV5ClientBuilder extends ResteasyGiteeClientBuilder {
|
||||
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
|
||||
public Integer apply(MergeRequest mergeRequest) {
|
||||
return mergeRequest.getIid();
|
||||
public Integer apply(PullRequest pullRequest) {
|
||||
return pullRequest.getIid();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -9,12 +9,13 @@ import com.google.common.base.Function;
|
|||
final class ResteasyGiteeClient implements GiteeClient {
|
||||
private final String hostUrl;
|
||||
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.api = api;
|
||||
this.mergeRequestIdProvider = mergeRequestIdProvider;
|
||||
this.pullRequestIdProvider = pullRequestIdProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,13 +25,13 @@ final class ResteasyGiteeClient implements GiteeClient {
|
|||
|
||||
// Gitee v5 don't support commit message and remove source branch
|
||||
@Override
|
||||
public void acceptMergeRequest(MergeRequest mr, String mergeCommitMessage, boolean shouldRemoveSourceBranch) {
|
||||
api.acceptMergeRequest(mr.getRepoOwner(), mr.getRepoPath(), mergeRequestIdProvider.apply(mr));
|
||||
public void acceptPullRequest(PullRequest mr, String mergeCommitMessage, boolean shouldRemoveSourceBranch) {
|
||||
api.acceptPullRequest(mr.getRepoOwner(), mr.getRepoPath(), mr.getIid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMergeRequestNote(MergeRequest mr, String body) {
|
||||
api.createMergeRequestNote(mr.getRepoOwner(), mr.getRepoPath(), mergeRequestIdProvider.apply(mr), body);
|
||||
public void createPullRequestNote(PullRequest mr, String body) {
|
||||
api.createPullRequestNote(mr.getRepoOwner(), mr.getRepoPath(), mr.getIid(), body);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,7 @@ package com.gitee.jenkins.gitee.api.impl;
|
|||
import com.gitee.jenkins.gitee.JacksonConfig;
|
||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||
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.LoggerUtil;
|
||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||
|
@ -67,12 +67,12 @@ public class ResteasyGiteeClientBuilder extends GiteeClientBuilder {
|
|||
}
|
||||
|
||||
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);
|
||||
this.apiProxyClass = apiProxyClass;
|
||||
this.mergeRequestIdProvider = mergeRequestIdProvider;
|
||||
this.pullRequestIdProvider = pullRequestIdProvider;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -124,7 +124,7 @@ public class ResteasyGiteeClientBuilder extends GiteeClientBuilder {
|
|||
.classloader(apiProxyClass.getClassLoader())
|
||||
.build();
|
||||
|
||||
return new ResteasyGiteeClient(url, apiProxy, mergeRequestIdProvider);
|
||||
return new ResteasyGiteeClient(url, apiProxy, pullRequestIdProvider);
|
||||
}
|
||||
|
||||
private String getHost(String url) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class Label {
|
|||
private String description;
|
||||
private long openIssuesCount;
|
||||
private long closedIssuesCount;
|
||||
private long openMergeRequestsCount;
|
||||
private long openPullRequestsCount;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
@ -65,12 +65,12 @@ public class Label {
|
|||
this.closedIssuesCount = closedIssuesCount;
|
||||
}
|
||||
|
||||
public long getOpenMergeRequestsCount() {
|
||||
return openMergeRequestsCount;
|
||||
public long getOpenPullRequestsCount() {
|
||||
return openPullRequestsCount;
|
||||
}
|
||||
|
||||
public void setOpenMergeRequestsCount(long openMergeRequestsCount) {
|
||||
this.openMergeRequestsCount = openMergeRequestsCount;
|
||||
public void setOpenPullRequestsCount(long openPullRequestsCount) {
|
||||
this.openPullRequestsCount = openPullRequestsCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,7 +85,7 @@ public class Label {
|
|||
return new EqualsBuilder()
|
||||
.append(openIssuesCount, label.openIssuesCount)
|
||||
.append(closedIssuesCount, label.closedIssuesCount)
|
||||
.append(openMergeRequestsCount, label.openMergeRequestsCount)
|
||||
.append(openPullRequestsCount, label.openPullRequestsCount)
|
||||
.append(name, label.name)
|
||||
.append(color, label.color)
|
||||
.append(description, label.description)
|
||||
|
@ -100,7 +100,7 @@ public class Label {
|
|||
.append(description)
|
||||
.append(openIssuesCount)
|
||||
.append(closedIssuesCount)
|
||||
.append(openMergeRequestsCount)
|
||||
.append(openPullRequestsCount)
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class Label {
|
|||
.append("description", description)
|
||||
.append("openIssuesCount", openIssuesCount)
|
||||
.append("closedIssuesCount", closedIssuesCount)
|
||||
.append("openMergeRequestsCount", openMergeRequestsCount)
|
||||
.append("openPullRequestsCount", openPullRequestsCount)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.gitee.jenkins.gitee.api.model;
|
||||
|
||||
import com.gitee.jenkins.gitee.hook.model.PullRequestObjectAttributes;
|
||||
import com.gitee.jenkins.gitee.hook.model.State;
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
|
@ -12,7 +13,7 @@ import java.util.List;
|
|||
* @author Robin Müller
|
||||
*/
|
||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||
public class MergeRequest {
|
||||
public class PullRequest {
|
||||
private Integer id;
|
||||
private Integer iid;
|
||||
private String sourceBranch;
|
||||
|
@ -34,9 +35,9 @@ public class MergeRequest {
|
|||
private String repoOwner;
|
||||
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,
|
||||
String description, String mergeStatus) {
|
||||
this.id = id;
|
||||
|
@ -50,7 +51,27 @@ public class MergeRequest {
|
|||
this.mergeStatus = mergeStatus;
|
||||
}
|
||||
|
||||
public MergeRequest(int id, int iid, String sourceBranch, String targetBranch, String title,
|
||||
public PullRequest(PullRequestObjectAttributes objectAttributes) {
|
||||
this.id = objectAttributes.getId();
|
||||
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;
|
||||
|
@ -64,10 +85,8 @@ public class MergeRequest {
|
|||
this.mergeStatus = mergeStatus;
|
||||
try {
|
||||
String[] path = pathWithNamespace.split("/");
|
||||
String repoOwner = path[0];
|
||||
String repoPath = path[1];
|
||||
this.repoOwner = repoOwner;
|
||||
this.repoPath = repoPath;
|
||||
this.repoOwner = path[0];
|
||||
this.repoPath = path[1];
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -241,7 +260,7 @@ public class MergeRequest {
|
|||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MergeRequest that = (MergeRequest) o;
|
||||
PullRequest that = (PullRequest) o;
|
||||
return new EqualsBuilder()
|
||||
.append(id, that.id)
|
||||
.append(iid, that.iid)
|
|
@ -14,7 +14,7 @@ public class NoteHook extends WebHook {
|
|||
|
||||
private User user;
|
||||
private Project project;
|
||||
private MergeRequestObjectAttributes mergeRequest;
|
||||
private PullRequestObjectAttributes pullRequest;
|
||||
private NoteObjectAttributes objectAttributes;
|
||||
|
||||
public User getUser() {
|
||||
|
@ -41,12 +41,12 @@ public class NoteHook extends WebHook {
|
|||
this.objectAttributes = objectAttributes;
|
||||
}
|
||||
|
||||
public MergeRequestObjectAttributes getMergeRequest() {
|
||||
return mergeRequest;
|
||||
public PullRequestObjectAttributes getPullRequest() {
|
||||
return pullRequest;
|
||||
}
|
||||
|
||||
public void setMergeRequest(MergeRequestObjectAttributes mergeRequest) {
|
||||
this.mergeRequest = mergeRequest;
|
||||
public void setPullRequest(PullRequestObjectAttributes pullRequest) {
|
||||
this.pullRequest = pullRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,7 +62,7 @@ public class NoteHook extends WebHook {
|
|||
.append(user, that.user)
|
||||
.append(project, that.project)
|
||||
.append(objectAttributes, that.objectAttributes)
|
||||
.append(mergeRequest, that.mergeRequest)
|
||||
.append(pullRequest, that.pullRequest)
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class NoteHook extends WebHook {
|
|||
.append(user)
|
||||
.append(project)
|
||||
.append(objectAttributes)
|
||||
.append(mergeRequest)
|
||||
.append(pullRequest)
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class NoteHook extends WebHook {
|
|||
.append("user", user)
|
||||
.append("project", project)
|
||||
.append("objectAttributes", objectAttributes)
|
||||
.append("mergeRequest", mergeRequest)
|
||||
.append("pullRequest", pullRequest)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,15 @@ import java.util.List;
|
|||
* @author Yashin Luo
|
||||
*/
|
||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||
public class MergeRequestHook extends WebHook {
|
||||
public class PullRequestHook extends WebHook {
|
||||
|
||||
private User user;
|
||||
private User assignee;
|
||||
private Project repo;
|
||||
private Action action;
|
||||
private State state;
|
||||
private MergeRequestObjectAttributes pullRequest;
|
||||
private List<MergeRequestLabel> labels;
|
||||
private PullRequestObjectAttributes pullRequest;
|
||||
private List<PullRequestLabel> labels;
|
||||
|
||||
public Action getAction() {
|
||||
return action;
|
||||
|
@ -63,19 +63,19 @@ public class MergeRequestHook extends WebHook {
|
|||
this.repo = repo;
|
||||
}
|
||||
|
||||
public MergeRequestObjectAttributes getPullRequest() {
|
||||
public PullRequestObjectAttributes getPullRequest() {
|
||||
return pullRequest;
|
||||
}
|
||||
|
||||
public void setPullRequest(MergeRequestObjectAttributes pullRequest) {
|
||||
public void setPullRequest(PullRequestObjectAttributes pullRequest) {
|
||||
this.pullRequest = pullRequest;
|
||||
}
|
||||
|
||||
public List<MergeRequestLabel> getLabels() {
|
||||
public List<PullRequestLabel> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void setLabels(List<MergeRequestLabel> labels) {
|
||||
public void setLabels(List<PullRequestLabel> labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class MergeRequestHook extends WebHook {
|
|||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MergeRequestHook that = (MergeRequestHook) o;
|
||||
PullRequestHook that = (PullRequestHook) o;
|
||||
return new EqualsBuilder()
|
||||
.append(user, that.user)
|
||||
.append(assignee, that.assignee)
|
|
@ -11,7 +11,7 @@ import java.util.Date;
|
|||
* @author Benjamin ROBIN
|
||||
*/
|
||||
@GeneratePojoBuilder(intoPackage = "*.builder.generated", withFactoryMethod = "*")
|
||||
public class MergeRequestLabel {
|
||||
public class PullRequestLabel {
|
||||
|
||||
/*
|
||||
"id": 206,
|
||||
|
@ -124,7 +124,7 @@ public class MergeRequestLabel {
|
|||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MergeRequestLabel that = (MergeRequestLabel) o;
|
||||
PullRequestLabel that = (PullRequestLabel) o;
|
||||
return new EqualsBuilder()
|
||||
.append(id, that.id)
|
||||
.append(title, that.title)
|
|
@ -1,6 +1,7 @@
|
|||
package com.gitee.jenkins.gitee.hook.model;
|
||||
|
||||
import net.karneim.pojobuilder.GeneratePojoBuilder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
|
@ -12,8 +13,11 @@ import java.util.Date;
|
|||
* @author Yashin
|
||||
*/
|
||||
@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 number;
|
||||
private Integer authorId;
|
||||
|
@ -175,6 +179,10 @@ public class MergeRequestObjectAttributes {
|
|||
this.workInProgress = workInProgress;
|
||||
}
|
||||
|
||||
public boolean can_be_merged() {
|
||||
return StringUtils.isNotBlank(mergeCommitSha) && !StringUtils.equals(CANNOT_BE_MERGED, mergeStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
@ -183,7 +191,7 @@ public class MergeRequestObjectAttributes {
|
|||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MergeRequestObjectAttributes that = (MergeRequestObjectAttributes) o;
|
||||
PullRequestObjectAttributes that = (PullRequestObjectAttributes) o;
|
||||
return new EqualsBuilder()
|
||||
.append(id, that.id)
|
||||
.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.model.MergeRequest;
|
||||
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Result;
|
||||
|
@ -21,11 +21,11 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public class GiteeAcceptMergeRequestPublisher extends MergeRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeAcceptMergeRequestPublisher.class.getName());
|
||||
public class GiteeAcceptPullRequestPublisher extends PullRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeAcceptPullRequestPublisher.class.getName());
|
||||
|
||||
@DataBoundConstructor
|
||||
public GiteeAcceptMergeRequestPublisher() { }
|
||||
public GiteeAcceptPullRequestPublisher() { }
|
||||
|
||||
public BuildStepMonitor getRequiredMonitorService() {
|
||||
return BuildStepMonitor.NONE;
|
||||
|
@ -41,19 +41,19 @@ public class GiteeAcceptMergeRequestPublisher extends MergeRequestNotifier {
|
|||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Messages.GiteeAcceptMergeRequestPublisher_DisplayName();
|
||||
return Messages.GiteeAcceptPullRequestPublisher_DisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest) {
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, PullRequest pullRequest) {
|
||||
try {
|
||||
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) {
|
||||
listener.getLogger().printf("Failed to accept merge request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to accept merge request for project '%s'", mergeRequest.getProjectId()), e);
|
||||
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 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.model.MergeRequest;
|
||||
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||
import com.gitee.jenkins.trigger.GiteePushTrigger;
|
||||
import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Result;
|
||||
import hudson.model.Run;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.model.*;
|
||||
import hudson.tasks.BuildStepDescriptor;
|
||||
import hudson.tasks.Notifier;
|
||||
import hudson.tasks.Publisher;
|
||||
import hudson.triggers.Trigger;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.model.ParameterizedJobMixIn;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.kohsuke.stapler.DataBoundSetter;
|
||||
|
||||
|
@ -26,7 +27,7 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* @author Nikolay Ustinov
|
||||
*/
|
||||
public class GiteeMessagePublisher extends MergeRequestNotifier {
|
||||
public class GiteeMessagePublisher extends PullRequestNotifier {
|
||||
private static final Logger LOGGER = Logger.getLogger(GiteeMessagePublisher.class.getName());
|
||||
private boolean onlyForFailure = false;
|
||||
private boolean replaceSuccessNote = false;
|
||||
|
@ -58,6 +59,20 @@ public class GiteeMessagePublisher extends MergeRequestNotifier {
|
|||
@DataBoundConstructor
|
||||
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() {
|
||||
return onlyForFailure;
|
||||
}
|
||||
|
@ -159,14 +174,14 @@ public class GiteeMessagePublisher extends MergeRequestNotifier {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, MergeRequest mergeRequest) {
|
||||
protected void perform(Run<?, ?> build, TaskListener listener, GiteeClient client, PullRequest pullRequest) {
|
||||
try {
|
||||
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) {
|
||||
listener.getLogger().printf("Failed to add comment on Merge Request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to add comment on Merge Request for project '%s'", mergeRequest.getProjectId()), e);
|
||||
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'", pullRequest.getProjectId()), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.publisher;
|
|||
|
||||
import com.gitee.jenkins.cause.GiteeWebHookCause;
|
||||
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.matrix.MatrixAggregatable;
|
||||
import hudson.matrix.MatrixAggregator;
|
||||
|
@ -21,7 +21,7 @@ import static com.gitee.jenkins.connection.GiteeConnectionProperty.getClient;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public abstract class MergeRequestNotifier extends Notifier implements MatrixAggregatable {
|
||||
public abstract class PullRequestNotifier extends Notifier implements MatrixAggregatable {
|
||||
public BuildStepMonitor getRequiredMonitorService() {
|
||||
return BuildStepMonitor.NONE;
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ public abstract class MergeRequestNotifier extends Notifier implements MatrixAgg
|
|||
return true;
|
||||
}
|
||||
|
||||
MergeRequest mergeRequest = getMergeRequest(build);
|
||||
if (mergeRequest != null) {
|
||||
perform(build, listener, client, mergeRequest);
|
||||
PullRequest pullRequest = getPullRequest(build);
|
||||
if (pullRequest != null) {
|
||||
perform(build, listener, client, pullRequest);
|
||||
}
|
||||
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);
|
||||
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.GiteeConnectionConfig;
|
||||
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.PipelineHook;
|
||||
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.trigger.filter.BranchFilter;
|
||||
import com.gitee.jenkins.trigger.filter.BranchFilterFactory;
|
||||
import com.gitee.jenkins.trigger.filter.BranchFilterType;
|
||||
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.filter.*;
|
||||
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilterConfig;
|
||||
import com.gitee.jenkins.trigger.handler.merge.PullRequestHookTriggerHandler;
|
||||
import com.gitee.jenkins.trigger.handler.note.NoteHookTriggerHandler;
|
||||
import com.gitee.jenkins.trigger.handler.pipeline.PipelineHookTriggerHandler;
|
||||
import com.gitee.jenkins.trigger.handler.push.PushHookTriggerHandler;
|
||||
|
@ -51,7 +47,7 @@ import java.io.ObjectStreamException;
|
|||
import java.security.SecureRandom;
|
||||
|
||||
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.pipeline.PipelineHookTriggerHandlerFactory.newPipelineHookTriggerHandler;
|
||||
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 boolean triggerOnPush = true;
|
||||
private boolean triggerOnOpenMergeRequest = true;
|
||||
private boolean triggerOnOpenPullRequest = true;
|
||||
private boolean triggerOnPipelineEvent = false;
|
||||
private boolean triggerOnAcceptedMergeRequest = false;
|
||||
private boolean triggerOnUpdateMergeRequest = false;
|
||||
private boolean triggerOnClosedMergeRequest = false;
|
||||
private boolean triggerOnApprovedMergeRequest = false;
|
||||
private boolean triggerOnTestedMergeRequest = false;
|
||||
private boolean triggerOnAcceptedPullRequest = false;
|
||||
private boolean triggerOnUpdatePullRequest = false;
|
||||
private boolean triggerOnClosedPullRequest = false;
|
||||
private boolean triggerOnApprovedPullRequest = false;
|
||||
private boolean triggerOnTestedPullRequest = false;
|
||||
private boolean triggerOnNoteRequest = true;
|
||||
private String noteRegex = "";
|
||||
private boolean ciSkip = true;
|
||||
private boolean skipWorkInProgressMergeRequest;
|
||||
private boolean skipWorkInProgressPullRequest;
|
||||
private boolean skipLastCommitHasBeenBuild;
|
||||
private boolean setBuildDescription = true;
|
||||
private transient boolean addNoteOnMergeRequest;
|
||||
private transient boolean addNoteOnPullRequest;
|
||||
private transient boolean addCiMessage;
|
||||
private transient boolean addVoteOnMergeRequest;
|
||||
private transient boolean addVoteOnPullRequest;
|
||||
private transient boolean allowAllBranches = false;
|
||||
private transient String branchFilterName;
|
||||
private BranchFilterType branchFilterType;
|
||||
private String includeBranchesSpec;
|
||||
private String excludeBranchesSpec;
|
||||
private String targetBranchRegex;
|
||||
private MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig;
|
||||
private PullRequestLabelFilterConfig pullRequestLabelFilterConfig;
|
||||
private volatile Secret secretToken;
|
||||
private String pendingBuildName;
|
||||
private boolean cancelPendingBuildsOnUpdate;
|
||||
|
||||
private transient BranchFilter branchFilter;
|
||||
private transient PushHookTriggerHandler pushHookTriggerHandler;
|
||||
private transient MergeRequestHookTriggerHandler mergeRequestHookTriggerHandler;
|
||||
private transient PullRequestHookTriggerHandler pullRequestHookTriggerHandler;
|
||||
private transient NoteHookTriggerHandler noteHookTriggerHandler;
|
||||
private transient PipelineHookTriggerHandler pipelineTriggerHandler;
|
||||
private transient boolean acceptMergeRequestOnSuccess;
|
||||
private transient MergeRequestLabelFilter mergeRequestLabelFilter;
|
||||
private transient boolean acceptPullRequestOnSuccess;
|
||||
private transient PullRequestLabelFilter pullRequestLabelFilter;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #GiteePushTrigger()} with setters to configure an instance of this class.
|
||||
*/
|
||||
@Deprecated
|
||||
@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 skipWorkInProgressMergeRequest, boolean ciSkip,
|
||||
boolean setBuildDescription, boolean addNoteOnMergeRequest, boolean addCiMessage, boolean addVoteOnMergeRequest,
|
||||
boolean acceptMergeRequestOnSuccess, BranchFilterType branchFilterType,
|
||||
boolean skipWorkInProgressPullRequest, boolean ciSkip,
|
||||
boolean setBuildDescription, boolean addNoteOnPullRequest, boolean addCiMessage, boolean addVoteOnPullRequest,
|
||||
boolean acceptPullRequestOnSuccess, BranchFilterType branchFilterType,
|
||||
String includeBranchesSpec, String excludeBranchesSpec, String targetBranchRegex,
|
||||
MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig, String secretToken, boolean triggerOnPipelineEvent,
|
||||
boolean triggerOnApprovedMergeRequest, String pendingBuildName, boolean cancelPendingBuildsOnUpdate) {
|
||||
PullRequestLabelFilterConfig pullRequestLabelFilterConfig, String secretToken, boolean triggerOnPipelineEvent,
|
||||
boolean triggerOnApprovedPullRequest, String pendingBuildName, boolean cancelPendingBuildsOnUpdate) {
|
||||
this.triggerOnPush = triggerOnPush;
|
||||
this.triggerOnOpenMergeRequest = triggerOnOpenMergeRequest;
|
||||
this.triggerOnUpdateMergeRequest = triggerOnUpdateMergeRequest;
|
||||
this.triggerOnAcceptedMergeRequest = triggerOnAcceptedMergeRequest;
|
||||
this.triggerOnClosedMergeRequest = triggerOnClosedMergeRequest;
|
||||
this.triggerOnOpenPullRequest = triggerOnOpenPullRequest;
|
||||
this.triggerOnUpdatePullRequest = triggerOnUpdatePullRequest;
|
||||
this.triggerOnAcceptedPullRequest = triggerOnAcceptedPullRequest;
|
||||
this.triggerOnClosedPullRequest = triggerOnClosedPullRequest;
|
||||
this.triggerOnNoteRequest = triggerOnNoteRequest;
|
||||
this.noteRegex = noteRegex;
|
||||
this.triggerOnPipelineEvent = triggerOnPipelineEvent;
|
||||
this.ciSkip = ciSkip;
|
||||
this.skipWorkInProgressMergeRequest = skipWorkInProgressMergeRequest;
|
||||
this.skipWorkInProgressPullRequest = skipWorkInProgressPullRequest;
|
||||
this.setBuildDescription = setBuildDescription;
|
||||
this.addNoteOnMergeRequest = addNoteOnMergeRequest;
|
||||
this.addNoteOnPullRequest = addNoteOnPullRequest;
|
||||
this.addCiMessage = addCiMessage;
|
||||
this.addVoteOnMergeRequest = addVoteOnMergeRequest;
|
||||
this.addVoteOnPullRequest = addVoteOnPullRequest;
|
||||
this.branchFilterType = branchFilterType;
|
||||
this.includeBranchesSpec = includeBranchesSpec;
|
||||
this.excludeBranchesSpec = excludeBranchesSpec;
|
||||
this.targetBranchRegex = targetBranchRegex;
|
||||
this.acceptMergeRequestOnSuccess = acceptMergeRequestOnSuccess;
|
||||
this.mergeRequestLabelFilterConfig = mergeRequestLabelFilterConfig;
|
||||
this.acceptPullRequestOnSuccess = acceptPullRequestOnSuccess;
|
||||
this.pullRequestLabelFilterConfig = pullRequestLabelFilterConfig;
|
||||
this.secretToken = Secret.fromString(secretToken);
|
||||
this.triggerOnApprovedMergeRequest = triggerOnApprovedMergeRequest;
|
||||
this.triggerOnApprovedPullRequest = triggerOnApprovedPullRequest;
|
||||
this.pendingBuildName = pendingBuildName;
|
||||
this.cancelPendingBuildsOnUpdate = cancelPendingBuildsOnUpdate;
|
||||
|
||||
initializeTriggerHandler();
|
||||
initializeBranchFilter();
|
||||
initializeMergeRequestLabelFilter();
|
||||
initializePullRequestLabelFilter();
|
||||
}
|
||||
|
||||
@DataBoundConstructor
|
||||
|
@ -180,11 +176,11 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
for (AbstractProject<?, ?> project : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
|
||||
GiteePushTrigger trigger = project.getTrigger(GiteePushTrigger.class);
|
||||
if (trigger != null) {
|
||||
if (trigger.addNoteOnMergeRequest) {
|
||||
if (trigger.addNoteOnPullRequest) {
|
||||
project.getPublishersList().add(new GiteeMessagePublisher());
|
||||
}
|
||||
if (trigger.acceptMergeRequestOnSuccess) {
|
||||
project.getPublishersList().add(new GiteeAcceptMergeRequestPublisher());
|
||||
if (trigger.acceptPullRequestOnSuccess) {
|
||||
project.getPublishersList().add(new GiteeAcceptPullRequestPublisher());
|
||||
}
|
||||
project.save();
|
||||
}
|
||||
|
@ -194,32 +190,34 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean getAddNoteOnPullRequest() { return addNoteOnPullRequest; }
|
||||
|
||||
public boolean getTriggerOnPush() {
|
||||
return triggerOnPush;
|
||||
}
|
||||
|
||||
public boolean getTriggerOnOpenMergeRequest() {
|
||||
return triggerOnOpenMergeRequest;
|
||||
public boolean getTriggerOnOpenPullRequest() {
|
||||
return triggerOnOpenPullRequest;
|
||||
}
|
||||
|
||||
public boolean getTriggerOnTestedMergeRequest() {
|
||||
return triggerOnTestedMergeRequest;
|
||||
public boolean getTriggerOnTestedPullRequest() {
|
||||
return triggerOnTestedPullRequest;
|
||||
}
|
||||
|
||||
public boolean getTriggerOnUpdateMergeRequest() {
|
||||
return triggerOnUpdateMergeRequest;
|
||||
public boolean getTriggerOnUpdatePullRequest() {
|
||||
return triggerOnUpdatePullRequest;
|
||||
}
|
||||
|
||||
public boolean isTriggerOnAcceptedMergeRequest() {
|
||||
return triggerOnAcceptedMergeRequest;
|
||||
public boolean isTriggerOnAcceptedPullRequest() {
|
||||
return triggerOnAcceptedPullRequest;
|
||||
}
|
||||
|
||||
public boolean isTriggerOnApprovedMergeRequest() {
|
||||
return triggerOnApprovedMergeRequest;
|
||||
public boolean isTriggerOnApprovedPullRequest() {
|
||||
return triggerOnApprovedPullRequest;
|
||||
}
|
||||
|
||||
public boolean isTriggerOnClosedMergeRequest() {
|
||||
return triggerOnClosedMergeRequest;
|
||||
public boolean isTriggerOnClosedPullRequest() {
|
||||
return triggerOnClosedPullRequest;
|
||||
}
|
||||
|
||||
public boolean getTriggerOnNoteRequest() {
|
||||
|
@ -244,8 +242,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
return skipLastCommitHasBeenBuild;
|
||||
}
|
||||
|
||||
public boolean isSkipWorkInProgressMergeRequest() {
|
||||
return skipWorkInProgressMergeRequest;
|
||||
public boolean isSkipWorkInProgressPullRequest() {
|
||||
return skipWorkInProgressPullRequest;
|
||||
}
|
||||
|
||||
public boolean isSkipLastCommitHasBuild() {
|
||||
|
@ -268,8 +266,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
return targetBranchRegex;
|
||||
}
|
||||
|
||||
public MergeRequestLabelFilterConfig getMergeRequestLabelFilterConfig() {
|
||||
return mergeRequestLabelFilterConfig;
|
||||
public PullRequestLabelFilterConfig getPullRequestLabelFilterConfig() {
|
||||
return pullRequestLabelFilterConfig;
|
||||
}
|
||||
|
||||
public String getSecretToken() {
|
||||
|
@ -290,28 +288,28 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setTriggerOnApprovedMergeRequest(boolean triggerOnApprovedMergeRequest) {
|
||||
this.triggerOnApprovedMergeRequest = triggerOnApprovedMergeRequest;
|
||||
public void setTriggerOnApprovedPullRequest(boolean triggerOnApprovedPullRequest) {
|
||||
this.triggerOnApprovedPullRequest = triggerOnApprovedPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setTriggerOnTestedMergeRequest(boolean triggerOnTestedMergeRequest) {
|
||||
this.triggerOnTestedMergeRequest = triggerOnTestedMergeRequest;
|
||||
public void setTriggerOnTestedPullRequest(boolean triggerOnTestedPullRequest) {
|
||||
this.triggerOnTestedPullRequest = triggerOnTestedPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setTriggerOnOpenMergeRequest(boolean triggerOnOpenMergeRequest) {
|
||||
this.triggerOnOpenMergeRequest = triggerOnOpenMergeRequest;
|
||||
public void setTriggerOnOpenPullRequest(boolean triggerOnOpenPullRequest) {
|
||||
this.triggerOnOpenPullRequest = triggerOnOpenPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setTriggerOnAcceptedMergeRequest(boolean triggerOnAcceptedMergeRequest) {
|
||||
this.triggerOnAcceptedMergeRequest = triggerOnAcceptedMergeRequest;
|
||||
public void setTriggerOnAcceptedPullRequest(boolean triggerOnAcceptedPullRequest) {
|
||||
this.triggerOnAcceptedPullRequest = triggerOnAcceptedPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setTriggerOnClosedMergeRequest(boolean triggerOnClosedMergeRequest) {
|
||||
this.triggerOnClosedMergeRequest = triggerOnClosedMergeRequest;
|
||||
public void setTriggerOnClosedPullRequest(boolean triggerOnClosedPullRequest) {
|
||||
this.triggerOnClosedPullRequest = triggerOnClosedPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
|
@ -330,8 +328,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setSkipWorkInProgressMergeRequest(boolean skipWorkInProgressMergeRequest) {
|
||||
this.skipWorkInProgressMergeRequest = skipWorkInProgressMergeRequest;
|
||||
public void setSkipWorkInProgressPullRequest(boolean skipWorkInProgressPullRequest) {
|
||||
this.skipWorkInProgressPullRequest = skipWorkInProgressPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
|
@ -347,8 +345,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setAddNoteOnMergeRequest(boolean addNoteOnMergeRequest) {
|
||||
this.addNoteOnMergeRequest = addNoteOnMergeRequest;
|
||||
public void setAddNoteOnPullRequest(boolean addNoteOnPullRequest) {
|
||||
this.addNoteOnPullRequest = addNoteOnPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
|
@ -357,8 +355,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setAddVoteOnMergeRequest(boolean addVoteOnMergeRequest) {
|
||||
this.addVoteOnMergeRequest = addVoteOnMergeRequest;
|
||||
public void setAddVoteOnPullRequest(boolean addVoteOnPullRequest) {
|
||||
this.addVoteOnPullRequest = addVoteOnPullRequest;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
|
@ -387,8 +385,8 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setMergeRequestLabelFilterConfig(MergeRequestLabelFilterConfig mergeRequestLabelFilterConfig) {
|
||||
this.mergeRequestLabelFilterConfig = mergeRequestLabelFilterConfig;
|
||||
public void setPullRequestLabelFilterConfig(PullRequestLabelFilterConfig pullRequestLabelFilterConfig) {
|
||||
this.pullRequestLabelFilterConfig = pullRequestLabelFilterConfig;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
|
@ -397,13 +395,13 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setAcceptMergeRequestOnSuccess(boolean acceptMergeRequestOnSuccess) {
|
||||
this.acceptMergeRequestOnSuccess = acceptMergeRequestOnSuccess;
|
||||
public void setAcceptPullRequestOnSuccess(boolean acceptPullRequestOnSuccess) {
|
||||
this.acceptPullRequestOnSuccess = acceptPullRequestOnSuccess;
|
||||
}
|
||||
|
||||
@DataBoundSetter
|
||||
public void setTriggerOnUpdateMergeRequest(boolean triggerOnUpdateMergeRequest) {
|
||||
this.triggerOnUpdateMergeRequest = triggerOnUpdateMergeRequest;
|
||||
public void setTriggerOnUpdatePullRequest(boolean triggerOnUpdatePullRequest) {
|
||||
this.triggerOnUpdatePullRequest = triggerOnUpdatePullRequest;
|
||||
}
|
||||
@DataBoundSetter
|
||||
public void setTriggerOnPipelineEvent(boolean triggerOnPipelineEvent) {
|
||||
|
@ -425,27 +423,27 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
if (branchFilter == null) {
|
||||
initializeBranchFilter();
|
||||
}
|
||||
if (mergeRequestLabelFilter == null) {
|
||||
initializeMergeRequestLabelFilter();
|
||||
if (pullRequestLabelFilter == null) {
|
||||
initializePullRequestLabelFilter();
|
||||
}
|
||||
if (pushHookTriggerHandler == null) {
|
||||
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
|
||||
public void onPost(final MergeRequestHook hook) {
|
||||
// executes when the Trigger receives a pull request
|
||||
public void onPost(final PullRequestHook hook) {
|
||||
if (branchFilter == null) {
|
||||
initializeBranchFilter();
|
||||
}
|
||||
if (mergeRequestLabelFilter == null) {
|
||||
initializeMergeRequestLabelFilter();
|
||||
if (pullRequestLabelFilter == null) {
|
||||
initializePullRequestLabelFilter();
|
||||
}
|
||||
if (mergeRequestHookTriggerHandler == null) {
|
||||
if (pullRequestHookTriggerHandler == null) {
|
||||
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
|
||||
|
@ -453,13 +451,13 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
if (branchFilter == null) {
|
||||
initializeBranchFilter();
|
||||
}
|
||||
if (mergeRequestLabelFilter == null) {
|
||||
initializeMergeRequestLabelFilter();
|
||||
if (pullRequestLabelFilter == null) {
|
||||
initializePullRequestLabelFilter();
|
||||
}
|
||||
if (noteHookTriggerHandler == null) {
|
||||
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
|
||||
|
@ -467,15 +465,15 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
if (pipelineTriggerHandler == null) {
|
||||
initializeTriggerHandler();
|
||||
}
|
||||
pipelineTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
||||
pipelineTriggerHandler.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||
}
|
||||
|
||||
private void initializeTriggerHandler() {
|
||||
mergeRequestHookTriggerHandler = newMergeRequestHookTriggerHandler(triggerOnOpenMergeRequest,
|
||||
triggerOnUpdateMergeRequest, triggerOnAcceptedMergeRequest, triggerOnClosedMergeRequest,
|
||||
skipWorkInProgressMergeRequest, triggerOnApprovedMergeRequest, triggerOnTestedMergeRequest, cancelPendingBuildsOnUpdate);
|
||||
pullRequestHookTriggerHandler = newPullRequestHookTriggerHandler(triggerOnOpenPullRequest,
|
||||
triggerOnUpdatePullRequest, triggerOnAcceptedPullRequest, triggerOnClosedPullRequest,
|
||||
skipWorkInProgressPullRequest, triggerOnApprovedPullRequest, triggerOnTestedPullRequest, cancelPendingBuildsOnUpdate);
|
||||
noteHookTriggerHandler = newNoteHookTriggerHandler(triggerOnNoteRequest, noteRegex);
|
||||
pushHookTriggerHandler = newPushHookTriggerHandler(triggerOnPush, skipWorkInProgressMergeRequest);
|
||||
pushHookTriggerHandler = newPushHookTriggerHandler(triggerOnPush, skipWorkInProgressPullRequest);
|
||||
pipelineTriggerHandler = newPipelineHookTriggerHandler(triggerOnPipelineEvent);
|
||||
}
|
||||
|
||||
|
@ -491,15 +489,15 @@ public class GiteePushTrigger extends Trigger<Job<?, ?>> {
|
|||
.build(branchFilterType));
|
||||
}
|
||||
|
||||
private void initializeMergeRequestLabelFilter() {
|
||||
mergeRequestLabelFilter = MergeRequestLabelFilterFactory.newMergeRequestLabelFilter(mergeRequestLabelFilterConfig);
|
||||
private void initializePullRequestLabelFilter() {
|
||||
pullRequestLabelFilter = PullRequestLabelFilterFactory.newPullRequestLabelFilter(pullRequestLabelFilterConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
initializeTriggerHandler();
|
||||
initializeBranchFilter();
|
||||
initializeMergeRequestLabelFilter();
|
||||
initializePullRequestLabelFilter();
|
||||
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
|
||||
*/
|
||||
class NopMergeRequestLabelFilter implements MergeRequestLabelFilter {
|
||||
class NopPullRequestLabelFilter implements PullRequestLabelFilter {
|
||||
@Override
|
||||
public boolean isMergeRequestAllowed(Collection<String> labels) {
|
||||
public boolean isPullRequestAllowed(Collection<String> labels) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,6 @@ import java.util.Collection;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public interface MergeRequestLabelFilter {
|
||||
boolean isMergeRequestAllowed(Collection<String> labels);
|
||||
public interface PullRequestLabelFilter {
|
||||
boolean isPullRequestAllowed(Collection<String> labels);
|
||||
}
|
|
@ -6,22 +6,22 @@ import org.kohsuke.stapler.DataBoundSetter;
|
|||
/**
|
||||
* @author Robin Müller
|
||||
*/
|
||||
public class MergeRequestLabelFilterConfig {
|
||||
public class PullRequestLabelFilterConfig {
|
||||
|
||||
private String include;
|
||||
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
|
||||
public MergeRequestLabelFilterConfig(String include, String exclude) {
|
||||
public PullRequestLabelFilterConfig(String include, String exclude) {
|
||||
this.include = include;
|
||||
this.exclude = exclude;
|
||||
}
|
||||
|
||||
@DataBoundConstructor
|
||||
public MergeRequestLabelFilterConfig() { }
|
||||
public PullRequestLabelFilterConfig() { }
|
||||
|
||||
public String getInclude() {
|
||||
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
|
||||
*/
|
||||
class MergeRequestLabelFilterImpl implements MergeRequestLabelFilter {
|
||||
class PullRequestLabelFilterImpl implements PullRequestLabelFilter {
|
||||
|
||||
private final Set<String> includeLabels;
|
||||
private final Set<String> excludeLabels;
|
||||
|
||||
public MergeRequestLabelFilterImpl(String includeLabels, String excludeLabels) {
|
||||
public PullRequestLabelFilterImpl(String includeLabels, String excludeLabels) {
|
||||
this.includeLabels = convert(includeLabels);
|
||||
this.excludeLabels = convert(excludeLabels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMergeRequestAllowed(Collection<String> labels) {
|
||||
public boolean isPullRequestAllowed(Collection<String> 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.trigger.exception.NoRevisionToBuildException;
|
||||
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 hudson.model.Action;
|
||||
import hudson.model.CauseAction;
|
||||
|
@ -34,7 +34,7 @@ public abstract class AbstractWebHookTriggerHandler<H extends WebHook> implement
|
|||
protected PendingBuildsHandler pendingBuildsHandler = new PendingBuildsHandler();
|
||||
|
||||
@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)) {
|
||||
LOGGER.log(Level.INFO, "Skipping due to ci-skip.");
|
||||
return;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler;
|
|||
|
||||
import com.gitee.jenkins.gitee.hook.model.WebHook;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -10,5 +10,5 @@ import hudson.model.Job;
|
|||
*/
|
||||
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.GiteeWebHookCause;
|
||||
import com.gitee.jenkins.gitee.hook.model.Action;
|
||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestHook;
|
||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestObjectAttributes;
|
||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestLabel;
|
||||
import com.gitee.jenkins.gitee.hook.model.State;
|
||||
import com.gitee.jenkins.gitee.api.GiteeClient;
|
||||
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||
import com.gitee.jenkins.gitee.hook.model.*;
|
||||
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||
import com.gitee.jenkins.publisher.GiteeMessagePublisher;
|
||||
import com.gitee.jenkins.trigger.GiteePushTrigger;
|
||||
import com.gitee.jenkins.trigger.exception.NoRevisionToBuildException;
|
||||
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.util.BuildUtil;
|
||||
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.trigger.handler.builder.generated.BuildStatusUpdateBuilder.buildStatusUpdate;
|
||||
import static com.gitee.jenkins.connection.GiteeConnectionProperty.getClient;
|
||||
|
||||
/**
|
||||
* @author Robin Müller
|
||||
* @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 boolean skipWorkInProgressMergeRequest;
|
||||
private final boolean skipWorkInProgressPullRequest;
|
||||
private final Collection<Action> allowedActions;
|
||||
private final boolean cancelPendingBuildsOnUpdate;
|
||||
|
||||
MergeRequestHookTriggerHandlerImpl(Collection<State> allowedStates, boolean skipWorkInProgressMergeRequest, boolean cancelPendingBuildsOnUpdate) {
|
||||
this(allowedStates, EnumSet.allOf(Action.class), skipWorkInProgressMergeRequest, cancelPendingBuildsOnUpdate);
|
||||
PullRequestHookTriggerHandlerImpl(Collection<State> allowedStates, boolean skipWorkInProgressPullRequest, boolean 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.allowedActions = allowedActions;
|
||||
this.skipWorkInProgressMergeRequest = skipWorkInProgressMergeRequest;
|
||||
this.skipWorkInProgressPullRequest = skipWorkInProgressPullRequest;
|
||||
this.cancelPendingBuildsOnUpdate = cancelPendingBuildsOnUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Job<?, ?> job, MergeRequestHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
|
||||
MergeRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
||||
public void handle(Job<?, ?> job, PullRequestHook hook, boolean ciSkip, boolean skipLastCommitHasBeenBuild, BranchFilter branchFilter, PullRequestLabelFilter pullRequestLabelFilter) {
|
||||
PullRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
||||
|
||||
try {
|
||||
LOGGER.log(Level.INFO, "request hook state=" + hook.getState() + ", action = " + hook.getAction() + " pr iid = " + objectAttributes.getNumber() + " hook name = " + hook.getHookName());
|
||||
if (isAllowedByConfig(hook)
|
||||
&& isNotSkipWorkInProgressMergeRequest(objectAttributes)) {
|
||||
&& isNotSkipWorkInProgressPullRequest(objectAttributes)) {
|
||||
List<String> labelsNames = new ArrayList<>();
|
||||
if (hook.getLabels() != null) {
|
||||
for (MergeRequestLabel label : hook.getLabels()) {
|
||||
for (PullRequestLabel label : hook.getLabels()) {
|
||||
labelsNames.add(label.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
if (mergeRequestLabelFilter.isMergeRequestAllowed(labelsNames)) {
|
||||
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
||||
// 若pr不可自动合并则评论至pr
|
||||
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 {
|
||||
|
@ -82,15 +95,15 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCiSkip(MergeRequestHook hook) {
|
||||
protected boolean isCiSkip(PullRequestHook hook) {
|
||||
return hook.getPullRequest() != null
|
||||
&& hook.getPullRequest().getBody() != null
|
||||
&& hook.getPullRequest().getBody().contains("[ci-skip]");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCommitSkip(Job<?, ?> project, MergeRequestHook hook) {
|
||||
MergeRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
||||
protected boolean isCommitSkip(Job<?, ?> project, PullRequestHook hook) {
|
||||
PullRequestObjectAttributes objectAttributes = hook.getPullRequest();
|
||||
|
||||
if (objectAttributes != null && objectAttributes.getMergeCommitSha() != null) {
|
||||
Run<?, ?> mergeBuild = BuildUtil.getBuildBySHA1IncludingMergeBuilds(project, objectAttributes.getMergeCommitSha());
|
||||
|
@ -103,7 +116,7 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void cancelPendingBuildsIfNecessary(Job<?, ?> job, MergeRequestHook hook) {
|
||||
protected void cancelPendingBuildsIfNecessary(Job<?, ?> job, PullRequestHook hook) {
|
||||
if (!this.cancelPendingBuildsOnUpdate) {
|
||||
return;
|
||||
}
|
||||
|
@ -114,17 +127,17 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getTargetBranch(MergeRequestHook hook) {
|
||||
protected String getTargetBranch(PullRequestHook hook) {
|
||||
return hook.getPullRequest() == null ? null : hook.getPullRequest().getTargetBranch();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTriggerType() {
|
||||
return "merge request";
|
||||
return "pull request";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CauseData retrieveCauseData(MergeRequestHook hook) {
|
||||
protected CauseData retrieveCauseData(PullRequestHook hook) {
|
||||
return causeData()
|
||||
.withActionType(CauseData.ActionType.MERGE)
|
||||
.withSourceProjectId(hook.getPullRequest().getSourceProjectId())
|
||||
|
@ -139,14 +152,14 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
|||
.withSourceRepoUrl(hook.getPullRequest().getSource().getUrl())
|
||||
.withSourceRepoSshUrl(hook.getPullRequest().getSource().getSshUrl())
|
||||
.withSourceRepoHttpUrl(hook.getPullRequest().getSource().getGitHttpUrl())
|
||||
.withMergeRequestTitle(hook.getPullRequest().getTitle())
|
||||
.withMergeRequestDescription(hook.getPullRequest().getBody())
|
||||
.withMergeRequestId(hook.getPullRequest().getId())
|
||||
.withMergeRequestIid(hook.getPullRequest().getNumber())
|
||||
.withMergeRequestState(hook.getState().toString())
|
||||
.withPullRequestTitle(hook.getPullRequest().getTitle())
|
||||
.withPullRequestDescription(hook.getPullRequest().getBody())
|
||||
.withPullRequestId(hook.getPullRequest().getId())
|
||||
.withPullRequestIid(hook.getPullRequest().getNumber())
|
||||
.withPullRequestState(hook.getState().toString())
|
||||
.withMergedByUser(hook.getUser() == null ? null : hook.getUser().getUsername())
|
||||
.withMergeRequestAssignee(hook.getAssignee() == null ? null : hook.getAssignee().getUsername())
|
||||
.withMergeRequestTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
||||
.withPullRequestAssignee(hook.getAssignee() == null ? null : hook.getAssignee().getUsername())
|
||||
.withPullRequestTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
||||
.withTargetBranch(hook.getPullRequest().getTargetBranch())
|
||||
.withTargetRepoName(hook.getPullRequest().getTarget().getName())
|
||||
.withTargetNamespace(hook.getPullRequest().getTarget().getNamespace())
|
||||
|
@ -160,12 +173,12 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
|||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BuildStatusUpdate retrieveBuildStatusUpdate(MergeRequestHook hook) {
|
||||
protected BuildStatusUpdate retrieveBuildStatusUpdate(PullRequestHook hook) {
|
||||
return buildStatusUpdate()
|
||||
.withProjectId(hook.getPullRequest().getSourceProjectId())
|
||||
.withSha(hook.getPullRequest().getMergeCommitSha())
|
||||
|
@ -173,7 +186,7 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
|||
.build();
|
||||
}
|
||||
|
||||
private String retrieveRevisionToBuild(MergeRequestHook hook) throws NoRevisionToBuildException {
|
||||
private String retrieveRevisionToBuild(PullRequestHook hook) throws NoRevisionToBuildException {
|
||||
if (hook.getPullRequest() != null
|
||||
&& hook.getPullRequest().getMergeReferenceName() != null) {
|
||||
return hook.getPullRequest().getMergeReferenceName();
|
||||
|
@ -187,15 +200,15 @@ class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<M
|
|||
return cause == null ? null : cause.getData().getTargetBranch();
|
||||
}
|
||||
|
||||
private boolean isAllowedByConfig(MergeRequestHook hook) {
|
||||
private boolean isAllowedByConfig(PullRequestHook hook) {
|
||||
return allowedStates.contains(hook.getState())
|
||||
&& allowedActions.contains(hook.getAction());
|
||||
}
|
||||
|
||||
// Gitee 无此状态,暂时屏蔽
|
||||
private boolean isNotSkipWorkInProgressMergeRequest(MergeRequestObjectAttributes objectAttributes) {
|
||||
private boolean isNotSkipWorkInProgressPullRequest(PullRequestObjectAttributes objectAttributes) {
|
||||
// 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()));
|
||||
// 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.trigger.filter.BranchFilter;
|
||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ import hudson.model.Job;
|
|||
*/
|
||||
class NopNoteHookTriggerHandler implements NoteHookTriggerHandler {
|
||||
@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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,19 +2,15 @@ package com.gitee.jenkins.trigger.handler.note;
|
|||
|
||||
import com.gitee.jenkins.cause.CauseData;
|
||||
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.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.util.BuildUtil;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Run;
|
||||
import hudson.plugins.git.GitSCM;
|
||||
import hudson.plugins.git.RevisionParameterAction;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -36,17 +32,17 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
|||
}
|
||||
|
||||
@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())) {
|
||||
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, mergeRequestLabelFilter);
|
||||
super.handle(job, hook, ciSkip, skipLastCommitHasBeenBuild, branchFilter, pullRequestLabelFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCiSkip(NoteHook hook) {
|
||||
return hook.getMergeRequest() != null
|
||||
&& hook.getMergeRequest().getBody() != null
|
||||
&& hook.getMergeRequest().getBody().contains("[ci-skip]");
|
||||
return hook.getPullRequest() != null
|
||||
&& hook.getPullRequest().getBody() != null
|
||||
&& hook.getPullRequest().getBody().contains("[ci-skip]");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +51,7 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
|||
}
|
||||
@Override
|
||||
protected String getTargetBranch(NoteHook hook) {
|
||||
return hook.getMergeRequest() == null ? null : hook.getMergeRequest().getTargetBranch();
|
||||
return hook.getPullRequest() == null ? null : hook.getPullRequest().getTargetBranch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,31 +63,31 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
|||
protected CauseData retrieveCauseData(NoteHook hook) {
|
||||
return causeData()
|
||||
.withActionType(CauseData.ActionType.NOTE)
|
||||
.withSourceProjectId(hook.getMergeRequest().getSourceProjectId())
|
||||
.withTargetProjectId(hook.getMergeRequest().getTargetProjectId())
|
||||
.withBranch(hook.getMergeRequest().getSourceBranch())
|
||||
.withSourceBranch(hook.getMergeRequest().getSourceBranch())
|
||||
.withUserName(hook.getMergeRequest().getHead().getUser().getName())
|
||||
.withUserEmail(hook.getMergeRequest().getHead().getUser().getEmail())
|
||||
.withSourceRepoHomepage(hook.getMergeRequest().getSource().getHomepage())
|
||||
.withSourceRepoName(hook.getMergeRequest().getSource().getName())
|
||||
.withSourceNamespace(hook.getMergeRequest().getSource().getNamespace())
|
||||
.withSourceRepoUrl(hook.getMergeRequest().getSource().getUrl())
|
||||
.withSourceRepoSshUrl(hook.getMergeRequest().getSource().getSshUrl())
|
||||
.withSourceRepoHttpUrl(hook.getMergeRequest().getSource().getGitHttpUrl())
|
||||
.withMergeRequestTitle(hook.getMergeRequest().getTitle())
|
||||
.withMergeRequestDescription(hook.getMergeRequest().getBody())
|
||||
.withMergeRequestId(hook.getMergeRequest().getId())
|
||||
.withMergeRequestIid(hook.getMergeRequest().getNumber())
|
||||
.withMergeRequestTargetProjectId(hook.getMergeRequest().getTargetProjectId())
|
||||
.withTargetBranch(hook.getMergeRequest().getTargetBranch())
|
||||
.withTargetRepoName(hook.getMergeRequest().getTarget().getName())
|
||||
.withTargetNamespace(hook.getMergeRequest().getTarget().getNamespace())
|
||||
.withTargetRepoSshUrl(hook.getMergeRequest().getTarget().getSshUrl())
|
||||
.withTargetRepoHttpUrl(hook.getMergeRequest().getTarget().getGitHttpUrl())
|
||||
.withTriggeredByUser(hook.getMergeRequest().getHead().getUser().getName())
|
||||
.withLastCommit(hook.getMergeRequest().getMergeCommitSha())
|
||||
.withTargetProjectUrl(hook.getMergeRequest().getTarget().getUrl())
|
||||
.withSourceProjectId(hook.getPullRequest().getSourceProjectId())
|
||||
.withTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
||||
.withBranch(hook.getPullRequest().getSourceBranch())
|
||||
.withSourceBranch(hook.getPullRequest().getSourceBranch())
|
||||
.withUserName(hook.getPullRequest().getHead().getUser().getName())
|
||||
.withUserEmail(hook.getPullRequest().getHead().getUser().getEmail())
|
||||
.withSourceRepoHomepage(hook.getPullRequest().getSource().getHomepage())
|
||||
.withSourceRepoName(hook.getPullRequest().getSource().getName())
|
||||
.withSourceNamespace(hook.getPullRequest().getSource().getNamespace())
|
||||
.withSourceRepoUrl(hook.getPullRequest().getSource().getUrl())
|
||||
.withSourceRepoSshUrl(hook.getPullRequest().getSource().getSshUrl())
|
||||
.withSourceRepoHttpUrl(hook.getPullRequest().getSource().getGitHttpUrl())
|
||||
.withPullRequestTitle(hook.getPullRequest().getTitle())
|
||||
.withPullRequestDescription(hook.getPullRequest().getBody())
|
||||
.withPullRequestId(hook.getPullRequest().getId())
|
||||
.withPullRequestIid(hook.getPullRequest().getNumber())
|
||||
.withPullRequestTargetProjectId(hook.getPullRequest().getTargetProjectId())
|
||||
.withTargetBranch(hook.getPullRequest().getTargetBranch())
|
||||
.withTargetRepoName(hook.getPullRequest().getTarget().getName())
|
||||
.withTargetNamespace(hook.getPullRequest().getTarget().getNamespace())
|
||||
.withTargetRepoSshUrl(hook.getPullRequest().getTarget().getSshUrl())
|
||||
.withTargetRepoHttpUrl(hook.getPullRequest().getTarget().getGitHttpUrl())
|
||||
.withTriggeredByUser(hook.getPullRequest().getHead().getUser().getName())
|
||||
.withLastCommit(hook.getPullRequest().getMergeCommitSha())
|
||||
.withTargetProjectUrl(hook.getPullRequest().getTarget().getUrl())
|
||||
.withTriggerPhrase(hook.getObjectAttributes().getNote())
|
||||
.build();
|
||||
}
|
||||
|
@ -104,17 +100,17 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
|||
@Override
|
||||
protected BuildStatusUpdate retrieveBuildStatusUpdate(NoteHook hook) {
|
||||
return buildStatusUpdate()
|
||||
.withProjectId(hook.getMergeRequest().getSourceProjectId())
|
||||
.withSha(hook.getMergeRequest().getMergeCommitSha())
|
||||
.withRef(hook.getMergeRequest().getSourceBranch())
|
||||
.withProjectId(hook.getPullRequest().getSourceProjectId())
|
||||
.withSha(hook.getPullRequest().getMergeCommitSha())
|
||||
.withRef(hook.getPullRequest().getSourceBranch())
|
||||
.build();
|
||||
}
|
||||
|
||||
private String retrieveRevisionToBuild(NoteHook hook) throws NoRevisionToBuildException {
|
||||
if (hook.getMergeRequest() != null
|
||||
&& hook.getMergeRequest().getMergeCommitSha() != null) {
|
||||
if (hook.getPullRequest() != null
|
||||
&& hook.getPullRequest().getMergeCommitSha() != null) {
|
||||
|
||||
return hook.getMergeRequest().getMergeCommitSha();
|
||||
return hook.getPullRequest().getMergeCommitSha();
|
||||
} else {
|
||||
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.trigger.filter.BranchFilter;
|
||||
import com.gitee.jenkins.trigger.filter.MergeRequestLabelFilter;
|
||||
import com.gitee.jenkins.trigger.filter.PullRequestLabelFilter;
|
||||
import hudson.model.Job;
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ import hudson.model.Job;
|
|||
class NopPipelineHookTriggerHandler implements PipelineHookTriggerHandler {
|
||||
|
||||
@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.trigger.exception.NoRevisionToBuildException;
|
||||
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.util.BuildUtil;
|
||||
import com.gitee.jenkins.util.LoggerUtil;
|
||||
|
@ -44,7 +44,7 @@ class PipelineHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<Pipel
|
|||
}
|
||||
|
||||
@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();
|
||||
try {
|
||||
if (job instanceof AbstractProject<?, ?>) {
|
||||
|
@ -109,7 +109,7 @@ class PipelineHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<Pipel
|
|||
.withSourceNamespace(hook.getProject()==null||hook.getProject().getNamespace()==null?"":hook.getProject().getNamespace())
|
||||
.withSourceRepoSshUrl(hook.getRepository()==null||hook.getRepository().getGitSshUrl()==null?"":hook.getRepository().getGitSshUrl())
|
||||
.withSourceRepoHttpUrl(hook.getRepository()==null||hook.getRepository()==null?"":hook.getRepository().getGitHttpUrl())
|
||||
.withMergeRequestTitle("")
|
||||
.withPullRequestTitle("")
|
||||
.withTargetProjectId(hook.getProjectId())
|
||||
.withTargetBranch(getTargetBranch(hook)==null?"":getTargetBranch(hook))
|
||||
.withTargetRepoName("")
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler.push;
|
|||
|
||||
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ import hudson.model.Job;
|
|||
*/
|
||||
class NopPushHookTriggerHandler implements PushHookTriggerHandler {
|
||||
@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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,15 @@ public final class PushHookTriggerHandlerFactory {
|
|||
|
||||
private PushHookTriggerHandlerFactory() {}
|
||||
|
||||
public static PushHookTriggerHandler newPushHookTriggerHandler(boolean triggerOnPush, boolean skipWorkInProgressMergeRequest) {
|
||||
public static PushHookTriggerHandler newPushHookTriggerHandler(boolean triggerOnPush, boolean skipWorkInProgressPullRequest) {
|
||||
if (triggerOnPush) {
|
||||
return new PushHookTriggerHandlerList(retrieveHandlers(triggerOnPush, skipWorkInProgressMergeRequest));
|
||||
return new PushHookTriggerHandlerList(retrieveHandlers(triggerOnPush, skipWorkInProgressPullRequest));
|
||||
} else {
|
||||
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<>();
|
||||
if (triggerOnPush) {
|
||||
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.trigger.exception.NoRevisionToBuildException;
|
||||
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 hudson.model.Job;
|
||||
import hudson.model.Run;
|
||||
|
@ -31,9 +31,9 @@ class PushHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<PushHook>
|
|||
private static final String NO_COMMIT = "0000000000000000000000000000000000000000";
|
||||
|
||||
@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)) {
|
||||
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())
|
||||
.withSourceRepoSshUrl(hook.getProject().getSshUrl())
|
||||
.withSourceRepoHttpUrl(hook.getProject().getGitHttpUrl())
|
||||
.withMergeRequestTitle("")
|
||||
.withMergeRequestDescription("")
|
||||
.withMergeRequestId(null)
|
||||
.withMergeRequestIid(null)
|
||||
.withMergeRequestState(null)
|
||||
.withPullRequestTitle("")
|
||||
.withPullRequestDescription("")
|
||||
.withPullRequestId(null)
|
||||
.withPullRequestIid(null)
|
||||
.withPullRequestState(null)
|
||||
.withMergedByUser("")
|
||||
.withMergeRequestAssignee("")
|
||||
.withMergeRequestTargetProjectId(null)
|
||||
.withPullRequestAssignee("")
|
||||
.withPullRequestTargetProjectId(null)
|
||||
.withTargetBranch(getTargetBranch(hook))
|
||||
.withTargetRepoName("")
|
||||
.withTargetNamespace("")
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.gitee.jenkins.trigger.handler.push;
|
|||
|
||||
import com.gitee.jenkins.gitee.hook.model.PushHook;
|
||||
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 java.util.List;
|
||||
|
@ -19,9 +19,9 @@ class PushHookTriggerHandlerList implements PushHookTriggerHandler {
|
|||
}
|
||||
|
||||
@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) {
|
||||
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;
|
||||
|
||||
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.PipelineBuildAction;
|
||||
import com.gitee.jenkins.webhook.build.PushBuildAction;
|
||||
|
@ -107,7 +107,7 @@ public class ActionResolver {
|
|||
String tokenHeader = request.getHeader("X-Gitee-Token");
|
||||
switch (eventHeader) {
|
||||
case "Merge Request Hook":
|
||||
return new MergeRequestBuildAction(project, getRequestBody(request), tokenHeader);
|
||||
return new PullRequestBuildAction(project, getRequestBody(request), tokenHeader);
|
||||
case "Push Hook":
|
||||
case "Tag Push Hook":
|
||||
return new PushBuildAction(project, getRequestBody(request), tokenHeader);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.gitee.jenkins.webhook.build;
|
||||
|
||||
import com.gitee.jenkins.gitee.hook.model.PullRequestHook;
|
||||
import com.gitee.jenkins.trigger.GiteePushTrigger;
|
||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestHook;
|
||||
import com.gitee.jenkins.gitee.hook.model.MergeRequestObjectAttributes;
|
||||
import com.gitee.jenkins.gitee.hook.model.PullRequestObjectAttributes;
|
||||
import com.gitee.jenkins.gitee.hook.model.Project;
|
||||
import com.gitee.jenkins.util.JsonUtil;
|
||||
import hudson.model.Item;
|
||||
|
@ -19,23 +19,23 @@ import static com.gitee.jenkins.util.JsonUtil.toPrettyPrint;
|
|||
/**
|
||||
* @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 MergeRequestHook mergeRequestHook;
|
||||
private PullRequestHook pullRequestHook;
|
||||
private final String secretToken;
|
||||
|
||||
public MergeRequestBuildAction(Item project, String json, String secretToken) {
|
||||
LOGGER.log(Level.FINE, "MergeRequest: {0}", toPrettyPrint(json));
|
||||
public PullRequestBuildAction(Item project, String json, String secretToken) {
|
||||
LOGGER.log(Level.FINE, "PullRequest: {0}", toPrettyPrint(json));
|
||||
this.project = project;
|
||||
this.mergeRequestHook = JsonUtil.read(json, MergeRequestHook.class);
|
||||
this.pullRequestHook = JsonUtil.read(json, PullRequestHook.class);
|
||||
this.secretToken = secretToken;
|
||||
}
|
||||
|
||||
void processForCompatibility() {
|
||||
// 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) {
|
||||
final Project source = attributes.getSource();
|
||||
if (source != null && source.getGitHttpUrl() != null) {
|
||||
|
@ -47,9 +47,9 @@ public class MergeRequestBuildAction extends BuildWebHookAction {
|
|||
}
|
||||
}
|
||||
|
||||
// The MergeRequestHookTriggerHandlerImpl is looking for Project
|
||||
if (mergeRequestHook.getRepo() == null && attributes.getTarget() != null) {
|
||||
mergeRequestHook.setRepo(attributes.getTarget());
|
||||
// The PullRequestHookTriggerHandlerImpl is looking for Project
|
||||
if (pullRequestHook.getRepo() == null && attributes.getTarget() != null) {
|
||||
pullRequestHook.setRepo(attributes.getTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,9 @@ public class MergeRequestBuildAction extends BuildWebHookAction {
|
|||
ACL.impersonate(ACL.SYSTEM, new TriggerNotifier(project, secretToken, Jenkins.getAuthentication()) {
|
||||
@Override
|
||||
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.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 hudson.Extension;
|
||||
|
@ -29,20 +29,20 @@ import hudson.model.TaskListener;
|
|||
* @author <a href="mailto:robin.mueller@1und1.de">Robin Müller</a>
|
||||
*/
|
||||
@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;
|
||||
|
||||
@DataBoundConstructor
|
||||
public AcceptGiteeMergeRequestStep(String mergeCommitMessage) {
|
||||
public AcceptGiteePullRequestStep(String mergeCommitMessage) {
|
||||
this.mergeCommitMessage = StringUtils.isEmpty(mergeCommitMessage) ? null : mergeCommitMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepExecution start(StepContext context) throws Exception {
|
||||
return new AcceptGiteeMergeRequestStepExecution(context, this);
|
||||
return new AcceptGiteePullRequestStepExecution(context, this);
|
||||
}
|
||||
|
||||
public String getMergeCommitMessage() {
|
||||
|
@ -54,14 +54,14 @@ public class AcceptGiteeMergeRequestStep extends Step {
|
|||
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 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);
|
||||
this.step = step;
|
||||
run = context.get(Run.class);
|
||||
|
@ -71,17 +71,17 @@ public class AcceptGiteeMergeRequestStep extends Step {
|
|||
protected Void run() throws Exception {
|
||||
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
||||
if (cause != null) {
|
||||
MergeRequest mergeRequest = cause.getData().getMergeRequest();
|
||||
if (mergeRequest != null) {
|
||||
PullRequest pullRequest = cause.getData().getPullRequest();
|
||||
if (pullRequest != null) {
|
||||
GiteeClient client = getClient(run);
|
||||
if (client == null) {
|
||||
println("No Gitee connection configured");
|
||||
} else {
|
||||
try {
|
||||
client.acceptMergeRequest(mergeRequest, step.mergeCommitMessage, false);
|
||||
client.acceptPullRequest(pullRequest, step.mergeCommitMessage, false);
|
||||
} catch (WebApplicationException | ProcessingException e) {
|
||||
printf("Failed to accept merge request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to accept merge request for project '%s'", mergeRequest.getProjectId()), e);
|
||||
printf("Failed to accept pull request for project '%s': %s%n", pullRequest.getProjectId(), e.getMessage());
|
||||
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.WebApplicationException;
|
||||
|
||||
import com.gitee.jenkins.gitee.api.model.PullRequest;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution;
|
||||
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.gitee.api.GiteeClient;
|
||||
import com.gitee.jenkins.gitee.api.model.MergeRequest;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import hudson.Extension;
|
||||
|
@ -32,20 +32,20 @@ import hudson.model.TaskListener;
|
|||
* @author <a href="mailto:robin.mueller@1und1.de">Robin Müller</a>
|
||||
*/
|
||||
@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;
|
||||
|
||||
@DataBoundConstructor
|
||||
public AddGiteeMergeRequestCommentStep(String comment) {
|
||||
public AddGiteePullRequestCommentStep(String comment) {
|
||||
this.comment = StringUtils.isEmpty(comment) ? null : comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepExecution start(StepContext context) throws Exception {
|
||||
return new AddGiteeMergeRequestCommentStepExecution(context, this);
|
||||
return new AddGiteePullRequestCommentStepExecution(context, this);
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
|
@ -57,14 +57,14 @@ public class AddGiteeMergeRequestCommentStep extends Step {
|
|||
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 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);
|
||||
this.step = step;
|
||||
run = context.get(Run.class);
|
||||
|
@ -74,17 +74,17 @@ public class AddGiteeMergeRequestCommentStep extends Step {
|
|||
protected Void run() throws Exception {
|
||||
GiteeWebHookCause cause = run.getCause(GiteeWebHookCause.class);
|
||||
if (cause != null) {
|
||||
MergeRequest mergeRequest = cause.getData().getMergeRequest();
|
||||
if (mergeRequest != null) {
|
||||
PullRequest pullRequest = cause.getData().getPullRequest();
|
||||
if (pullRequest != null) {
|
||||
GiteeClient client = getClient(run);
|
||||
if (client == null) {
|
||||
println("No Gitee connection configured");
|
||||
} else {
|
||||
try {
|
||||
client.createMergeRequestNote(mergeRequest, step.getComment());
|
||||
client.createPullRequestNote(pullRequest, step.getComment());
|
||||
} catch (WebApplicationException | ProcessingException e) {
|
||||
printf("Failed to add comment on Merge Request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage());
|
||||
LOGGER.log(Level.SEVERE, String.format("Failed to add comment on Merge Request for project '%s'", mergeRequest.getProjectId()), e);
|
||||
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'", pullRequest.getProjectId()), e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
GiteeWebHookCause.ShortDescription.PushHook_noUser=Started by Gitee push
|
||||
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.MergeRequestHook_plain=Triggered by Gitee Pull Request #{0}: {1} => {2}
|
||||
GiteeWebHookCause.ShortDescription.PullRequestHook_html=Triggered by <a href="{3}/pulls/{0}" target="_blank">Gitee Pull Request #{0}</a>: {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_plain=Triggered by {0} Gitee Pull Request #{1}: {2} => {3}
|
||||
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=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.MergeRequestHook_plain=\u7531 Gitee Pull Request #{0}: {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.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_plain=\u7531 {0} Gitee Pull Request #{1}: {2} => {3} \u89E6\u53D1
|
||||
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=\u7531 Gitee Pipeline \u89E6\u53D1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
GiteeCommitStatusPublisher.DisplayName=Publish build status to Gitee
|
||||
name.required=Build name required.
|
||||
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
|
||||
name.required=\u8BF7\u8F93\u5165\u6784\u5EFA\u540D\u79F0\u3002
|
||||
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:checkbox default="true"/>
|
||||
</f:entry>
|
||||
<f:entry title="${%Opened.Pull.Request}" field="triggerOnOpenMergeRequest">
|
||||
<f:entry title="${%Opened.Pull.Request}" field="triggerOnOpenPullRequest">
|
||||
<f:checkbox default="true"/>
|
||||
</f:entry>
|
||||
<f:entry title="${%Updated.Pull.Request}" field="triggerOnUpdateMergeRequest">
|
||||
<f:entry title="${%Updated.Pull.Request}" field="triggerOnUpdatePullRequest">
|
||||
<f:checkbox default="true"/>
|
||||
</f:entry>
|
||||
<f:entry title="${%Accepted.Pull.Request}" field="triggerOnAcceptedMergeRequest">
|
||||
<f:entry title="${%Accepted.Pull.Request}" field="triggerOnAcceptedPullRequest">
|
||||
<f:checkbox default="false"/>
|
||||
</f:entry>
|
||||
<f:entry title="${%Closed.Pull.Request}" field="triggerOnClosedMergeRequest">
|
||||
<f:entry title="${%Closed.Pull.Request}" field="triggerOnClosedPullRequest">
|
||||
<f:checkbox default="false"/>
|
||||
</f:entry>
|
||||
<f:entry title="${%Approved.Pull.Request}" field="triggerOnApprovedMergeRequest">
|
||||
<f:entry title="${%Approved.Pull.Request}" field="triggerOnApprovedPullRequest">
|
||||
<f:checkbox default="false"/>
|
||||
</f:entry>
|
||||
<f:entry title="${%Tested.Pull.Request}" field="triggerOnTestedMergeRequest">
|
||||
<f:entry title="${%Tested.Pull.Request}" field="triggerOnTestedPullRequest">
|
||||
<f:checkbox default="false"/>
|
||||
</f:entry>
|
||||
</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.regex=Filter branches by 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
|
||||
Include=Include
|
||||
Ignore.Last.Commit.Has.Build=Ignore last commit has been build
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
This plugin integrates
|
||||
<a href="http://gitee.com/">Gitee</a>
|
||||
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.
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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>
|
|
@ -1,3 +1,3 @@
|
|||
<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>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div>
|
||||
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.
|
||||
If you have more than one, select the appropriate one from the 'Gitee connection' dropdown menu in the job configuration.
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue