gitgithubjenkinsghprb

Proper configuration for Jenkins GitHub Pull Request Builder downstream


I'm trying to create two Jenkins jobs that both leverage the GitHub Pull Request Builder plugin in order to run multiple status checks, but I'm having trouble getting the status check from my downstream job to show up in my GitHub project.

Here's the summarized CI flow I'd like to setup:

  1. A pull request is opened against my git repository which triggers Upstream job to run in Jenkins
  2. Upstream reports its status based on the build and, if SUCCESS, should invoke Downstream job via a post-build action
  3. Downstream runs and reports its own status check

Step 3 is where I'm having issues. Downstream runs properly, but it does not post a status. The status is not even available under the Branches section of my GitHub project's settings. I'm not sure how GHPRB does the initial creation of the status check, but there are references to the context messaging in the Console Output:

14:58:23 Started by upstream project "upstream" build number 209
14:58:23 originally caused by:
14:58:23  GitHub pull request #114 of commit f1ff2819a5308f7819275e732cf44a2cc2ec31dc, no merge conflicts.
14:58:23 [EnvInject] - Loading node environment variables.
14:58:23 Building on master in workspace /store/jenkins/jobs/downstream/workspace
14:58:23  > git rev-parse --is-inside-work-tree # timeout=10
14:58:23 Fetching changes from the remote Git repository
14:58:23  > git config remote.origin.url <removed for privacy> # timeout=10
14:58:23 Fetching upstream changes from <removed for privacy>
14:58:23  > git --version # timeout=10
14:58:23  > git -c core.askpass=true fetch --tags --progress <removed for privacy> +refs/pull/*:refs/remotes/origin/pr/*
14:58:24  > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
14:58:24  > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
14:58:24 Checking out Revision eac390c51a1b8b591bfe879421bd5fad0421a1ec (refs/remotes/origin/master)
14:58:24  > git config core.sparsecheckout # timeout=10
14:58:24  > git checkout -f eac390c51a1b8b591bfe879421bd5fad0421a1ec
14:58:24 First time build. Skipping changelog.
14:58:24 [build] $ /store/jenkins/tools/hudson.tasks.Ant_AntInstallation/ant_1.8.2/bin/ant -DghprbStatusUrl= "-DghprbSUCCESSMessage=Packaging organization successfully cleaned" -DghprbStartedStatus=Undeploying -DghprbAddTestResults=false "-DghprbCommitStatusContext=Cleaning Packaging" "-DghprbERRORMessage=An error occurred during undeployment" -DghprbUpstreamStatus=true "-DghprbTriggeredStatus=Preparing destructive changes" "-DghprbFAILUREMessage=Packaging organization failed to clean properly" -DghprbShowMatrixStatus=false

Here are the relevant configuration sections for both Jenkins jobs:


Upstream Job

Source Code Management: Git

Build Triggers

Post-build Actions


Downstream Job

Source Code Management: Git

Build Triggers

Build Environment


What am I missing? It should be noted that I do not have the Jobs DSL plugin installed so I cannot leverage the extension that GHPRB provides.


Solution

  • After extensive trial and error, this comment shed some light on my issue.

    The crux of my issue was that Downstream was not receiving required environment variables that GHPRB provides. Namely ghprbGhRepository, ghprbPullId, ghprbActualCommit and sha1.

    The correct configurations for both jobs are as follows:


    Upstream Job

    Source Code Management: Git

    Build Triggers

    Build


    Downstream Job

    Source Code Management: Git

    Build Environment