Skip to content

Commit

Permalink
Added support for jenkins github pull request builder environment var…
Browse files Browse the repository at this point in the history
…iables
  • Loading branch information
fracmak committed May 14, 2015
1 parent 4ca3f16 commit 9020e1f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/services/jenkins.js
Expand Up @@ -9,10 +9,11 @@ module.exports = {
if (!env) env = process.env;
return {
service : 'jenkins',
commit : env.GIT_COMMIT,
branch : env.GIT_BRANCH,
commit : env.ghprbActualCommit || env.GIT_COMMIT,
branch : env.ghprbSourceBranch || env.GIT_BRANCH,
build : env.BUILD_NUMBER,
build_url : env.BUILD_URL,
pull_request : env.ghprbPullId,
root : env.WORKSPACE
};
}
Expand Down
21 changes: 21 additions & 0 deletions test/services/jenkins.js
Expand Up @@ -19,7 +19,28 @@ describe("jenkins service", function(){
build : '1234',
commit : '5678',
root : '/var/lib/jenkins/workspace',
pull_request : undefined,
branch : 'master'
});
});

it ("github pull request env variables win out over jenkins variables", function(){
process.env.BUILD_NUMBER = '1234';
process.env.BUILD_URL = 'http://asdf/';
process.env.GIT_COMMIT = '5678';
process.env.ghprbActualCommit = '8765';
process.env.GIT_BRANCH = 'master';
process.env.ghprbSourceBranch = 'retsam';
process.env.ghprbPullId = '1111';
process.env.WORKSPACE = '/var/lib/jenkins/workspace';
expect(jenkins.configuration()).to.eql({
service : 'jenkins',
build_url : 'http://asdf/',
build : '1234',
commit : '8765',
root : '/var/lib/jenkins/workspace',
pull_request : '1111',
branch : 'retsam'
});
});
});

0 comments on commit 9020e1f

Please sign in to comment.