-
Configure github-plugin according to it’s documentation.
-
Set
GitHub project propertywith link to your GitHub repository in Job settings.
-
Advanced section contains configuration for configuring
GitHub Repository Provider. Provider is source of connection to GitHub used by Triggers. Trigger may do automatic hooks registration, but it requiresADMINlevel access for user and OAuth scopes for token based connection. Trigger may not work when it can’t get connection to GitHub so you may want to tune it for example with usingPULLperms for building some upstream project orPUSHwith ability to set commit status contexts (green/red checkboxes per commit).
-
Configure git-plugin: add any repo name i.e. 'origin-pull' and set refspec to
+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/mergeif you want run build for merged state or '/head' for building exact PR commits, or$GITHUB_PR_COND_REFif you want 'head' state when PR is not mergeable (according to GH state). Set branch specifier toorigin-pull/pull/${GITHUB_PR_NUMBER}/merge. This exact link allows to speedup fetch sources. -
Enable "Build GitHub Pull Requests" trigger and configure it.
-
Under
Trigger Eventsadd eventNot mergeableand checkSkip building unmergeable pull requests?. As using above branch specifier silently checks out commits up to the point PR was mergeable without complaining. Alternatively, for error indication use Branch Trigger and merge using git commands. -
If you want do gatekeepering, then add second repository with i.e. origin. Add
Mergeextension in from Git SCM and configure post build action for push action.
-
If you want to set commit status right before job was put to Jenkins queue, enable
Set status before buildcheckbox in trigger configuration (it will have no links because there is no real builds in jenkins, only queue item that is not a build) -
In
BuildsectionAdd Build stepcalledGitHub PR: set pull request status to "pending"and enter some message likeBuild #${BUILD_NUMBER} started -
In
Post-build ActionsaddGitHub PR: set PR statusand configure message toBuild #${BUILD_NUMBER} ended
-
GITHUB_PR_TRIGGER_SENDER_AUTHOR-Kanstantsin Shautsou -
GITHUB_PR_TRIGGER_SENDER_EMAIL-KostyaSha@users.noreply.github.com -
GITHUB_PR_COMMIT_AUTHOR_NAME -
GITHUB_PR_COMMIT_AUTHOR_EMAIL -
GITHUB_PR_TARGET_BRANCH-master -
GITHUB_PR_SOURCE_BRANCH-KostyaSha-patch-9 -
GITHUB_PR_AUTHOR_EMAIL-KostyaSha@users.noreply.github.com -
GITHUB_PR_BODY- -
GITHUB_PR_SHORT_DESC- -
GITHUB_PR_TITLE-Update README.md -
GITHUB_PR_URL-KostyaSha/test-repo#21 -
GITHUB_PR_SOURCE_REPO_OWNER-KostyaSha -
GITHUB_PR_HEAD_SHA-8c8e496391619410bded8bb113d4887443ea3b53 -
GITHUB_PR_COND_REF-head -
GITHUB_PR_CAUSE_SKIP-false -
GITHUB_PR_NUMBER-21 -
GITHUB_PR_STATE-OPEN -
GITHUB_PR_COMMENT_BODY-test foo, bar tags please.When PR was triggered by comment. -
GITHUB_PR_COMMENT_BODY_MATCH-foo, barWhen PR wass triggered by comment and had group match. -
GITHUB_PR_LABELS-label1,label2Comma-separated list of labels that the PR has. Empty if the PR has no labels.
-
Configure Git SCM with variables refspec:
refs/heads/${GITHUB_BRANCH_NAME}:refs/remotes/origin/${GITHUB_BRANCH_NAME}url${GITHUB_REPO_GIT_URL}, branchspec${GITHUB_BRANCH_NAME}.
-
GITHUB_BRANCH_NAME-KostyaSha-patch-1 -
GITHUB_BRANCH_SHORT_DESC -
GITHUB_BRANCH_TITLE -
GITHUB_BRANCH_URL -
GITHUB_BRANCH_HEAD_SHA-850f36c6e494c5d85c748e61337647f003106bfb -
GITHUB_BRANCH_FULL_REF-refs/heads/KostyaSha-patch-1 -
GITHUB_BRANCH_CAUSE_SKIP-trueorfalse