@@ -38,6 +38,26 @@
userAgent: 'octokit/rest.js v16.23.2',
});
}
+exports.getAppVeyorBuildUrl = () => {
+ if (!process.env.APPVEYOR) {
+ return;
+ }
+ const { APPVEYOR_URL, APPVEYOR_ACCOUNT_NAME, APPVEYOR_PROJECT_SLUG, APPVEYOR_BUILD_ID, } = process.env;
+ if (!APPVEYOR_URL ||
+ !APPVEYOR_ACCOUNT_NAME ||
+ !APPVEYOR_BUILD_ID ||
+ !APPVEYOR_PROJECT_SLUG) {
+ console.error('Hmm, cannot find build environment variables on AppVeyor CI');
+ return;
+ }
+ return `${APPVEYOR_URL}/project/${APPVEYOR_ACCOUNT_NAME}/${APPVEYOR_PROJECT_SLUG}/builds/${APPVEYOR_BUILD_ID}`;
+};
+/**
+ * Returns the current build job url based on built-in environment variables on various CIs
+ * @see CircleCI https://circleci.com/docs/2.0/env-vars/
+ * @see AppVeyor https://www.appveyor.com/docs/environment-variables/
+ */
+exports.getTargetUrl = () => process.env.CIRCLE_BUILD_URL || exports.getAppVeyorBuildUrl();
var GitHub;
(function (GitHub) {
/**
@@ -87,17 +107,23 @@
function setCommitStatus(options, gh) {
return __awaiter(this, void 0, void 0, function* () {
debug('setting commit status %o', options);
- // https://octokit.github.io/rest.js/#api-Repos-createStatus
- yield gh.repos.createStatus({
+ let targetUrl = options.targetUrl || exports.getTargetUrl();
+ const ghOptions = {
owner: options.owner,
repo: options.repo,
sha: options.sha,
state: options.state || StatusState.pending,
- target_url: options.targetUrl,
+ target_url: targetUrl,
description: options.description,
context: options.context,
- });
- debug('created commit status: %s/%s sha %s state %s', options.owner, options.repo, options.sha, options.state);
+ };
+ debug('resolved commit status options %o', ghOptions);
+ // https://octokit.github.io/rest.js/#api-Repos-createStatus
+ yield gh.repos.createStatus(ghOptions);
+ debug('created commit status: %s/%s sha %s state %s', ghOptions.owner, ghOptions.repo, ghOptions.sha, ghOptions.state);
+ if (ghOptions.target_url) {
+ debug('with details at %s', ghOptions.target_url);
+ }
});
}
GitHub.setCommitStatus = setCommitStatus;