screwdriver-coverage-sonar 4.1.0 → 4.1.1
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/index.js +29 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -116,27 +116,40 @@ class CoverageSonar extends CoverageBase {
|
|
|
116
116
|
method: 'GET',
|
|
117
117
|
url: `${this.sonarHost}/api/alm_settings/get_binding?project=${componentId}`,
|
|
118
118
|
username: this.adminToken
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
})
|
|
120
|
+
.then(result => {
|
|
121
|
+
// if project name has been changed, update it
|
|
122
|
+
if (projectName && (!result.repository || result.repository !== projectName)) {
|
|
123
|
+
throw new Error(`Repository name has been changed from ${result.repository} to ${projectName}!`);
|
|
124
|
+
}
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
return result;
|
|
127
|
+
})
|
|
128
|
+
.catch(() => {
|
|
129
|
+
// if binding does not exist, add it
|
|
130
|
+
logger.info(`Binding does not exist for Sonar project ${projectKey}, adding`);
|
|
131
|
+
|
|
132
|
+
if (!this.sonarEnterprise || !projectName) {
|
|
133
|
+
return Promise.resolve();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const parameters = `almSetting=${gitAppEncoded}&project=${componentId}&repository=${projectName}&summaryCommentEnabled=true&monorepo=false`;
|
|
126
137
|
|
|
127
|
-
|
|
138
|
+
logger.info(`Configuring git app with following parameters, ${parameters}`);
|
|
128
139
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
return request({
|
|
141
|
+
method: 'POST',
|
|
142
|
+
url: `${this.sonarHost}/api/alm_settings/set_github_binding?${parameters}`,
|
|
143
|
+
username: this.adminToken
|
|
144
|
+
}).catch(error => {
|
|
145
|
+
// if cannot configure app, do not throw err
|
|
146
|
+
logger.error(
|
|
147
|
+
`Failed to configure Git App ${gitApp} for Sonar project ${projectKey}: ${error.message}`
|
|
148
|
+
);
|
|
136
149
|
|
|
137
|
-
|
|
150
|
+
return Promise.resolve();
|
|
151
|
+
});
|
|
138
152
|
});
|
|
139
|
-
});
|
|
140
153
|
}
|
|
141
154
|
|
|
142
155
|
/**
|