screwdriver-api 7.0.22 → 7.0.24
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 +1 -1
- package/plugins/coverage/token.js +47 -38
package/package.json
CHANGED
|
@@ -64,6 +64,8 @@ module.exports = config => ({
|
|
|
64
64
|
throw boom.notFound(`Pipeline ${pipelineId} does not exist`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
logger.info(`looking up pipeline from:${pipelineId}, and found pipeline:${pipeline}`);
|
|
68
|
+
|
|
67
69
|
tokenConfig.pipelineName = pipeline.name;
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -82,50 +84,57 @@ module.exports = config => ({
|
|
|
82
84
|
|
|
83
85
|
const selfSonar = new CoveragePlugin(selfSonarConfig);
|
|
84
86
|
const data = await selfSonar.coveragePlugin.getAccessToken(tokenConfig);
|
|
85
|
-
const projectUrl = selfSonar.coveragePlugin.getProjectData(tokenConfig);
|
|
86
|
-
|
|
87
|
-
if (pipeline && projectUrl) {
|
|
88
|
-
try {
|
|
89
|
-
const pipelineSonarBadge = {
|
|
90
|
-
defaultName: pipelineId,
|
|
91
|
-
defaultUri: projectUrl
|
|
92
|
-
};
|
|
93
|
-
let shouldPipelineUpdate = true;
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
pipeline.badges &&
|
|
97
|
-
pipeline.badges.sonar &&
|
|
98
|
-
pipeline.badges.sonar.defaultName === pipelineId &&
|
|
99
|
-
pipeline.badges.sonar.defaultUri === projectUrl
|
|
100
|
-
) {
|
|
101
|
-
shouldPipelineUpdate = false;
|
|
102
|
-
}
|
|
103
87
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
88
|
+
return h.response(data);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const data = await config.coveragePlugin.getAccessToken(tokenConfig);
|
|
92
|
+
const { projectUrl } = config.coveragePlugin.getProjectData(tokenConfig);
|
|
93
|
+
|
|
94
|
+
if (!pipeline && pipelineId) {
|
|
95
|
+
pipeline = await pipelineFactory.get(pipelineId);
|
|
96
|
+
|
|
97
|
+
logger.info(`looking up again, pipeline:${pipelineId}, and found pipeline: ${pipeline}`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (pipeline && projectUrl) {
|
|
101
|
+
try {
|
|
102
|
+
const pipelineSonarBadge = {
|
|
103
|
+
defaultName: `${pipelineId}`, // ensure pipelineId is stored as String instead of Integer
|
|
104
|
+
defaultUri: projectUrl
|
|
105
|
+
};
|
|
106
|
+
let shouldPipelineUpdate = true;
|
|
107
|
+
|
|
108
|
+
if (
|
|
109
|
+
pipeline.badges &&
|
|
110
|
+
pipeline.badges.sonar &&
|
|
111
|
+
pipeline.badges.sonar.defaultName === pipelineId &&
|
|
112
|
+
pipeline.badges.sonar.defaultUri === projectUrl
|
|
113
|
+
) {
|
|
114
|
+
shouldPipelineUpdate = false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (shouldPipelineUpdate) {
|
|
118
|
+
if (pipeline.badges) {
|
|
119
|
+
pipeline.badges.sonar = pipelineSonarBadge;
|
|
120
|
+
} else {
|
|
121
|
+
pipeline.badges = {
|
|
122
|
+
sonar: pipelineSonarBadge
|
|
123
|
+
};
|
|
117
124
|
}
|
|
118
|
-
} catch (err) {
|
|
119
|
-
logger.error(`Failed to update pipeline:${pipelineId}`, err);
|
|
120
125
|
|
|
121
|
-
|
|
126
|
+
await pipeline.update();
|
|
122
127
|
}
|
|
123
|
-
}
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
logger.info(
|
|
130
|
+
`update pipeline:${pipeline.id}'s sonar badge with pipeline.badges, ${pipeline.badges}`
|
|
131
|
+
);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
logger.error(`Failed to update pipeline:${pipelineId}`, err);
|
|
127
134
|
|
|
128
|
-
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
129
138
|
|
|
130
139
|
return h.response(data);
|
|
131
140
|
}
|