Skip to content

Latest commit

 

History

History
62 lines (55 loc) · 3.24 KB

File metadata and controls

62 lines (55 loc) · 3.24 KB

GitHub integration plugin

Pull Requests Trigger

Triggering

  • Configure github-plugin according to it’s documentation.

  • Set GitHub project property with link to your GitHub repository in Job settings.

  • 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}/merge if you want run build for merged state or '/head' for building exact PR commits, or $GITHUB_PR_COND_REF if you want 'head' state when PR is not mergeable (according to GH state). Set branch specifier to origin-pull/pull/${GITHUB_PR_NUMBER}/merge. This exact link allows to speedup fetch sources.

  • Enable "Build GitHub Pull Requests" trigger and configure it.

  • If you want do gatekeepering, then add second repository with i.e. origin. Add Merge extension in from Git SCM and configure post build action for push action.

Commit/PR statuses

  • If you want to set commit status right before job was put to Jenkins queue, enable Set status before build checkbox 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 Build section Add Build step called GitHub PR: set pull request status to "pending" and enter some message like Build #${BUILD_NUMBER} started

  • In Post-build Actions add GitHub PR: set PR status and configure message to Build #${BUILD_NUMBER} ended

Available Environment Variables:

  • GITHUB_PR_TRIGGER_SENDER_AUTHOR - Kanstantsin Shautsou

  • GITHUB_PR_TRIGGER_SENDER_EMAIL - [email protected]

  • 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 - [email protected]

  • 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

Branch Trigger

Triggering

  • Configure github-plugin according to it’s documentation.

  • Set GitHub project property with link to your GH repository in Job settings.

  • 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}.

Available Environment Variables

Specific for branch:
  • 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 - true or false

Specific for repo:
  • GITHUB_REPO_GIT_URL - git://github.com/KostyaSha-org/test-branches.git

  • GITHUB_REPO_SSH_URL - [email protected]:KostyaSha-org/test-branches.git