This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Seth Yates
committed
Apr 27, 2016
1 parent
2beff29
commit da0e882
Showing
6 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# common | ||
coverage | ||
node_modules | ||
*.log | ||
.DS_Store | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
sudo: false | ||
|
||
language: node_js | ||
|
||
cache: | ||
directories: | ||
- node_modules | ||
|
||
notifications: | ||
email: false | ||
|
||
node_js: | ||
- 5 | ||
|
||
before_install: | ||
- npm i -g npm@^2.0.0 | ||
|
||
before_script: | ||
- npm prune | ||
|
||
after_success: | ||
- npm run coverage:upload | ||
- npm run semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
# condition-jenkins | ||
|
||
[![npm version](https://badge.fury.io/js/%40krux%2Fcondition-jenkins.svg)](http://badge.fury.io/js/%40krux%2Fcondition-jenkins) | ||
[![Build Status](https://jenkins-ci.org/krux/condition-jenkins.svg)](https://jenkins-ci.org/krux/condition-jenkins) | ||
[![Coverage Status](https://coveralls.io/repos/krux/condition-jenkins/badge.svg?service=github)](https://coveralls.io/github/krux/condition-jenkins) | ||
|
||
[![Dependency Status](https://david-dm.org/krux/condition-jenkins/master.svg)](https://david-dm.org/krux/condition-jenkins/master) | ||
[![devDependency Status](https://david-dm.org/krux/condition-jenkins/master/dev-status.svg)](https://david-dm.org/krux/condition-jenkins/master#info=devDependencies) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var SRError = require('@semantic-release/error') | ||
|
||
module.exports = function (pluginConfig, config, cb) { | ||
var env = config.env | ||
var options = config.options | ||
|
||
if (!env.hasOwnProperty('JENKINS_URL')) { | ||
return cb(new SRError( | ||
'semantic-release didn’t run on Jenkins CI and therefore a new version won’t be published.\n' + | ||
'You can customize this behavior using "verifyConditions" plugins: git.io/sr-plugins', | ||
'ENOJENKINS' | ||
)) | ||
} | ||
|
||
if (options.branch !== env.GIT_BRANCH) { | ||
return cb(new SRError( | ||
'This test run was triggered on the branch ' + env.GIT_BRANCH + | ||
', while semantic-release is configured to only publish from ' + | ||
options.branch + '.\n' + | ||
'You can customize this behavior using the "branch" option: git.io/sr-options', | ||
'EBRANCHMISMATCH' | ||
)) | ||
} | ||
|
||
cb(null) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "@krux/condition-jenkins", | ||
"description": "make sure things only the right builds on jenkins get published", | ||
"version": "0.0.0-placeholder", | ||
"author": "Stephan Bönnemann <[email protected]> (http://boennemann.me)", | ||
"bugs": { | ||
"url": "https://github.com/krux/condition-jenkins/issues" | ||
}, | ||
"dependencies": { | ||
"@semantic-release/error": "^1.0.0", | ||
"semver": "^5.0.3" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.2", | ||
"nyc": "^5.0.0", | ||
"proxyquire": "^1.7.1", | ||
"semantic-release": "^6.0.3", | ||
"standard": "^6.0.3", | ||
"tap": "^5.0.0" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"homepage": "https://github.com/krux/condition-jenkins#readme", | ||
"keywords": [ | ||
"publish", | ||
"release", | ||
"semantic-release", | ||
"jenkins-ci" | ||
], | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public", | ||
"tag": "next" | ||
}, | ||
"release": { | ||
"branch": "next" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/krux/condition-jenkins.git" | ||
}, | ||
"scripts": { | ||
"coverage": "nyc report", | ||
"coverage:upload": "npm run -s coverage -- --reporter=text-lcov | coveralls", | ||
"pretest": "standard", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post", | ||
"test": "nyc tap --no-cov test.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
var proxyquire = require('proxyquire') | ||
var test = require('tap').test | ||
var SRError = require('@semantic-release/error') | ||
|
||
var condition = proxyquire('./', {}) | ||
|
||
test('raise errors in jenkins environment', function (t) { | ||
t.test('only runs on jenkins', function (tt) { | ||
tt.plan(2) | ||
|
||
condition({}, {env: {}}, function (err) { | ||
tt.ok(err instanceof SRError) | ||
tt.is(err.code, 'ENOJENKINS') | ||
}) | ||
}) | ||
|
||
t.test('only running on specified branch', function (tt) { | ||
tt.plan(5) | ||
|
||
condition({}, { | ||
env: { | ||
JENKINS_URL: 'http://localhost/', | ||
GIT_BRANCH: 'origin/master' | ||
}, | ||
options: { | ||
branch: 'origin/master' | ||
} | ||
}, function (err) { | ||
tt.is(err, null) | ||
}) | ||
|
||
condition({}, { | ||
env: { | ||
JENKINS_URL: 'http://localhost/', | ||
GIT_BRANCH: 'origin/notmaster' | ||
}, | ||
options: { | ||
branch: 'origin/master' | ||
} | ||
}, function (err) { | ||
tt.ok(err instanceof SRError) | ||
tt.is(err.code, 'EBRANCHMISMATCH') | ||
}) | ||
|
||
condition({}, { | ||
env: { | ||
JENKINS_URL: 'http://localhost/', | ||
GIT_BRANCH: 'origin/master' | ||
}, | ||
options: { | ||
branch: 'origin/foo' | ||
} | ||
}, function (err) { | ||
tt.ok(err instanceof SRError) | ||
tt.is(err.code, 'EBRANCHMISMATCH') | ||
}) | ||
}) | ||
|
||
t.end() | ||
}) |