screwdriver-api 8.0.36 → 8.0.38

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": "8.0.36",
3
+ "version": "8.0.38",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -153,7 +153,11 @@ module.exports = () => ({
153
153
 
154
154
  // Update admins
155
155
  if (!prNum) {
156
- await updateAdmins({ permissions, pipeline, user });
156
+ try {
157
+ await updateAdmins({ permissions, pipeline, user });
158
+ } catch (err) {
159
+ throw boom.boomify(err, { statusCode: err.statusCode });
160
+ }
157
161
  }
158
162
 
159
163
  // Get scmConfig
@@ -171,16 +175,21 @@ module.exports = () => ({
171
175
  payload.prNum = String(prNum);
172
176
  payload.type = 'pr';
173
177
 
174
- const [files, prInfo] = await Promise.all([
175
- scm.getChangedFiles({
176
- webhookConfig: null,
177
- type: 'pr',
178
- ...scmConfig
179
- }),
180
- scm.getPrInfo(scmConfig)
181
- ]).catch(err => {
178
+ let files;
179
+ let prInfo;
180
+
181
+ try {
182
+ [files, prInfo] = await Promise.all([
183
+ scm.getChangedFiles({
184
+ webhookConfig: null,
185
+ type: 'pr',
186
+ ...scmConfig
187
+ }),
188
+ scm.getPrInfo(scmConfig)
189
+ ]);
190
+ } catch (err) {
182
191
  throw boom.boomify(err, { statusCode: err.statusCode });
183
- });
192
+ }
184
193
 
185
194
  if (files && files.length) {
186
195
  payload.changedFiles = files;
@@ -196,14 +205,17 @@ module.exports = () => ({
196
205
  restrictPR = pipeline.annotations[ANNOT_RESTRICT_PR];
197
206
  }
198
207
 
199
- // PR author should be able to rerun their own PR build if restrictPR is not on
200
208
  if (restrictPR !== 'none' || prInfo.username !== username) {
201
209
  // Remove user from admins
202
- await updateAdmins({
203
- permissions,
204
- pipeline,
205
- user
206
- });
210
+ try {
211
+ await updateAdmins({
212
+ permissions,
213
+ pipeline,
214
+ user
215
+ });
216
+ } catch (err) {
217
+ throw boom.boomify(err, { statusCode: err.statusCode });
218
+ }
207
219
  }
208
220
  }
209
221
 
@@ -778,11 +778,17 @@ async function createPrClosedEvent(options, request) {
778
778
  try {
779
779
  const b = await p.branch;
780
780
  let eventConfig = {};
781
-
782
- let configPipelineSha = '';
781
+ const token = await p.token;
782
+ const pScmConfig = {
783
+ scmUri: p.scmUri,
784
+ token,
785
+ scmRepo: p.scmRepo,
786
+ scmContext: scmConfig.scmContext
787
+ };
788
+ let latestPipelineSha = '';
783
789
 
784
790
  try {
785
- configPipelineSha = await pipelineFactory.scm.getCommitSha(scmConfig);
791
+ latestPipelineSha = await pipelineFactory.scm.getCommitSha(pScmConfig);
786
792
  } catch (err) {
787
793
  if (err.status >= 500) {
788
794
  throw err;
@@ -808,14 +814,14 @@ async function createPrClosedEvent(options, request) {
808
814
  webhooks: true,
809
815
  username,
810
816
  scmContext: scmConfig.scmContext,
811
- sha,
817
+ sha: latestPipelineSha || sha,
812
818
  startFrom: isPipelineBranch ? startFrom : `${startFrom}:${branch}`,
813
819
  changedFiles,
814
820
  causeMessage: isPipelineBranch ? causeMessage : `${causeMessage} on branch ${branch}`,
815
821
  ref,
816
822
  baseBranch: branch,
817
823
  meta: createMeta(options),
818
- configPipelineSha,
824
+ configPipelineSha: latestPipelineSha,
819
825
  prNum,
820
826
  chainPR: resolvedChainPR
821
827
  };