-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(checks): add support for Jenkins CI (#322)
Includes a ci check handler to verify jenkins. Unlike other ci systems jenkins doesn't generally prefix things with `JENKINS` or simply inject `JENKINS=true` Really the only thing that is immediately identifiable is `JENKINS_URL`
- Loading branch information
1 parent
d51b999
commit 3e99855
Showing
2 changed files
with
50 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
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,33 @@ | ||
import pytest | ||
|
||
from semantic_release import ci_checks | ||
from semantic_release.errors import CiVerificationError | ||
|
||
def test_jenkins_should_pass_if_url_set_branch_master_no_pr(monkeypatch): | ||
monkeypatch.setenv("JENKINS_URL", "http://custom.jenkins.int.com") | ||
monkeypatch.setenv("BRANCH_NAME", "master") | ||
|
||
assert ci_checks.jenkins("master") | ||
|
||
|
||
def test_jenkins_should_pass_if_url_set_if_branch_correct_no_pr(monkeypatch): | ||
monkeypatch.setenv("JENKINS_URL", "http://custom.jenkins.int.com") | ||
monkeypatch.setenv("GIT_BRANCH", "foo-bar") | ||
|
||
assert ci_checks.jenkins("foo-bar") | ||
|
||
|
||
def test_jenkins_should_raise_ci_verification_error_no_url(monkeypatch): | ||
monkeypatch.setenv("BRANCH_NAME", "foo-bar") | ||
|
||
with pytest.raises(CiVerificationError): | ||
assert ci_checks.jenkins("foo-bar") | ||
|
||
|
||
def test_jenkins_should_raise_ci_verification_error_for_pr(monkeypatch): | ||
monkeypatch.setenv("JENKINS_URL", "http://custom.jenkins.int.com") | ||
monkeypatch.setenv("BRANCH_NAME", "foo-bar") | ||
monkeypatch.setenv("CHANGE_ID", "1") | ||
|
||
with pytest.raises(CiVerificationError): | ||
assert ci_checks.jenkins("foo-bar") |