Skip to content

Commit

Permalink
fix(1058): Pass in creator and causeMessage to new event (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyi authored Apr 16, 2019
1 parent e125047 commit aa5bbc5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ npm-debug.log
.DS_STORE
.*.swp
.nyc_output
package-lock.json
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ExecutorQueue extends Executor {
* @param {String} config.apiUri Base URL of the Screwdriver API
* @return {Promise}
*/
async postBuildEvent({ pipeline, job, apiUri, eventId }) {
async postBuildEvent({ pipeline, job, apiUri, eventId, causeMessage }) {
const pipelineInstance = await this.pipelineFactory.get(pipeline.id);
const admin = await pipelineInstance.getFirstAdmin();
const jwt = this.userTokenGen(admin.username, {}, pipeline.scmContext);
Expand All @@ -201,7 +201,12 @@ class ExecutorQueue extends Executor {
json: true,
body: {
pipelineId: pipeline.id,
startFrom: job.name
startFrom: job.name,
creator: {
name: 'Screwdriver scheduler',
username: 'sd:scheduler'
},
causeMessage: causeMessage || 'Automatically started by scheduler'
},
maxAttempts: RETRY_LIMIT,
retryDelay: RETRY_DELAY * 1000, // in ms
Expand Down Expand Up @@ -289,6 +294,8 @@ class ExecutorQueue extends Executor {
}

if (triggerBuild) {
config.causeMessage = 'Started by periodic build scheduler';

return this.postBuildEvent(config)
.catch((err) => {
winston.error(`failed to post build event for job ${job.id}: ${err}`);
Expand Down Expand Up @@ -349,7 +356,8 @@ class ExecutorQueue extends Executor {
const newConfig = {
job: {
name: config.jobName
}
},
causeMessage: 'Started by freeze window scheduler'
};

Object.assign(newConfig, config);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"chai": "^4.2.0",
"eslint": "^4.19.1",
"eslint-config-screwdriver": "^3.0.1",
"jenkins-mocha": "^6.0.0",
"jenkins-mocha": "^7.0.0",
"mockery": "^2.0.0",
"sinon": "^4.5.0"
},
Expand All @@ -47,7 +47,7 @@
"ioredis": "^3.2.2",
"node-resque": "^4.0.9",
"requestretry": "^3.1.0",
"screwdriver-data-schema": "^18.44.1",
"screwdriver-data-schema": "^18.45.2",
"screwdriver-executor-base": "^7.0.0",
"string-hash": "^1.1.3",
"winston": "^2.4.4"
Expand Down
2 changes: 2 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ describe('index test', () => {
},
json: true,
body: {
causeMessage: 'Started by periodic build scheduler',
creator: { name: 'Screwdriver scheduler', username: 'sd:scheduler' },
pipelineId: testDelayedConfig.pipeline.id,
startFrom: testDelayedConfig.job.name
},
Expand Down

0 comments on commit aa5bbc5

Please sign in to comment.