screwdriver-api 7.0.230 → 7.0.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "7.0.230",
3
+ "version": "7.0.231",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -294,6 +294,7 @@ async function createExternalEvent(config) {
294
294
  * @param {Boolean} config.start Whether to start the build or not
295
295
  * @param {Number|undefined} config.jobId Job ID
296
296
  * @param {EventModel} config.event Event build belongs to
297
+ * @param {String} config.causeMessage Reason the event is run
297
298
  * @returns {Promise<BuildModel|null>}
298
299
  */
299
300
  async function createInternalBuild(config) {
@@ -309,7 +310,8 @@ async function createInternalBuild(config) {
309
310
  start,
310
311
  baseBranch,
311
312
  parentBuildId,
312
- jobId
313
+ jobId,
314
+ causeMessage
313
315
  } = config;
314
316
  const { ref = '', prSource = '', prBranchName = '', url = '' } = event.pr || {};
315
317
  const prInfo = prBranchName ? { url, prBranchName } : '';
@@ -334,7 +336,8 @@ async function createInternalBuild(config) {
334
336
  prSource,
335
337
  prInfo,
336
338
  start: start !== false,
337
- baseBranch
339
+ baseBranch,
340
+ causeMessage
338
341
  };
339
342
 
340
343
  let jobState = job.state;
@@ -609,9 +612,10 @@ async function getParentBuildStatus({ newBuild, joinListNames, pipelineId, build
609
612
  * @param {String|undefined} arg.pipelineId Pipeline ID
610
613
  * @param {String|undefined} arg.stageName Stage name
611
614
  * @param {Boolean} arg.isVirtualJob If the job is virtual or not
615
+ * @param {Event} arg.event Event
612
616
  * @returns {Promise<Build|null>} The newly updated/created build
613
617
  */
614
- async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, stageName, isVirtualJob }) {
618
+ async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, stageName, isVirtualJob, event }) {
615
619
  if (!done || Status.isStarted(newBuild.status)) {
616
620
  return null;
617
621
  }
@@ -647,7 +651,9 @@ async function handleNewBuild({ done, hasFailure, newBuild, job, pipelineId, sta
647
651
  newBuild.status = Status.QUEUED;
648
652
  await newBuild.update();
649
653
 
650
- return newBuild.start();
654
+ const causeMessage = job.name === event.startFrom ? event.causeMessage : '';
655
+
656
+ return newBuild.start({ causeMessage });
651
657
  }
652
658
 
653
659
  /**
@@ -105,7 +105,8 @@ class JoinBase {
105
105
  job: nextJob,
106
106
  pipelineId,
107
107
  isVirtualJob: isNextJobVirtual,
108
- stageName: nextJobStageName
108
+ stageName: nextJobStageName,
109
+ event
109
110
  });
110
111
  }
111
112
  }
@@ -50,6 +50,8 @@ class OrBase {
50
50
  const hasFreezeWindows =
51
51
  nextJob.permutations[0].freezeWindows && nextJob.permutations[0].freezeWindows.length > 0;
52
52
 
53
+ const causeMessage = nextJob.name === event.startFrom ? event.causeMessage : '';
54
+
53
55
  if (nextBuild !== null) {
54
56
  if (Status.isStarted(nextBuild.status)) {
55
57
  return nextBuild;
@@ -67,7 +69,7 @@ class OrBase {
67
69
  nextBuild.status = Status.QUEUED;
68
70
  await nextBuild.update();
69
71
 
70
- return nextBuild.start();
72
+ return nextBuild.start({ causeMessage });
71
73
  }
72
74
 
73
75
  nextBuild = await createInternalBuild({
@@ -82,7 +84,8 @@ class OrBase {
82
84
  baseBranch: event.baseBranch || null,
83
85
  parentBuilds,
84
86
  parentBuildId: this.currentBuild.id,
85
- start: hasFreezeWindows || !isNextJobVirtual
87
+ start: hasFreezeWindows || !isNextJobVirtual,
88
+ causeMessage
86
89
  });
87
90
 
88
91
  // Bypass execution of the build if the job is virtual