Skip to content

Commit f6b4e8f

Browse files
tk3fftkd2lam
authored andcommitted
fix: use jobName as context on create status (#74)
* change status label to Screwdriver/<pipeline_id>/PR:<job_name>
1 parent 07c8780 commit f6b4e8f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,10 @@ class GithubScm extends Scm {
422422
scmUri: config.scmUri,
423423
token: config.token
424424
}).then((scmInfo) => {
425-
let context = `Screwdriver/${config.pipelineId}/`;
426-
427-
context += /^PR/.test(config.jobName) ? 'PR' : config.jobName;
425+
const jobName = config.jobName.replace(/^PR-\d+/g, 'PR');
428426

429427
const params = {
430-
context,
428+
context: `Screwdriver/${config.pipelineId}/${jobName}`,
431429
description: DESCRIPTION_MAP[config.buildStatus],
432430
repo: scmInfo.repo,
433431
sha: config.sha,

test/index.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ describe('index', function () {
461461
);
462462

463463
it('sets context for PR when jobName passed in', () => {
464-
config.jobName = 'PR-15';
464+
config.jobName = 'PR-15:test';
465465

466466
return scm.updateCommitStatus(config)
467467
.then((result) => {
@@ -473,7 +473,7 @@ describe('index', function () {
473473
sha: config.sha,
474474
state: 'success',
475475
description: 'Everything looks good!',
476-
context: 'Screwdriver/675/PR',
476+
context: 'Screwdriver/675/PR:test',
477477
target_url: 'https://foo.bar'
478478
});
479479
assert.calledWith(githubMock.authenticate, {
@@ -560,7 +560,8 @@ describe('index', function () {
560560
sha: 'ccc49349d3cffbd12ea9e3d41521480b4aa5de5f',
561561
buildStatus: 'SUCCESS',
562562
token: 'somerandomtoken',
563-
url: 'https://foo.bar'
563+
url: 'https://foo.bar',
564+
jobName: 'main'
564565
};
565566

566567
githubMock.repos.getById.yieldsAsync(null, {

0 commit comments

Comments
 (0)