Skip to content

Commit 26d8ca0

Browse files
author
Anatoly Bolshakov
authored
Added valid link to created PR (#15119)
1 parent 2ac137f commit 26d8ca0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ci/courtesy-push/open-courtesy-push-pull-request.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
const azdev = require('azure-devops-node-api');
22

3+
/**
4+
* Gets PR's link from pull request id - since url property of GitPullRequest returns JSON
5+
*/
6+
function getPullRequestLink(repositoryWebUrl, pullRequestId) {
7+
return `${repositoryWebUrl}/pullrequest/${pullRequestId}`;
8+
}
9+
310
const orgUrl = "https://dev.azure.com/mseng";
411
const token = process.env.TOKEN;
512
if (!token) {
@@ -27,9 +34,10 @@ console.log('Getting api');
2734
connection.getGitApi().then(gitApi => {
2835
console.log('Creating PR');
2936
gitApi.createPullRequest(pullRequestToCreate, azureDevOpsRepoId, project).then(res => {
30-
console.log(`Created PR ${res.url}`);
31-
const prLink = res.url || 'https://dev.azure.com/mseng/AzureDevOps/_git/AzureDevOps/pullrequests?_a=active&createdBy=fe107a2d-fcce-6506-8e35-5554dbe120fd';
32-
console.log(`##vso[task.setvariable variable=PrLink]${prLink}`);
37+
const prLink = getPullRequestLink(res.repository.webUrl, res.pullRequestId);
38+
console.log(`Created PR ${prLink}`);
39+
const prLinkRes = prLink || 'https://dev.azure.com/mseng/AzureDevOps/_git/AzureDevOps/pullrequests?_a=active&createdBy=fe107a2d-fcce-6506-8e35-5554dbe120fd';
40+
console.log(`##vso[task.setvariable variable=PrLink]${prLinkRes}`);
3341
}).catch(err => {
3442
console.log(err);
3543
throw err;

0 commit comments

Comments
 (0)