Ilkay Ilknur
Ilkay Ilknur

Reputation: 913

Adding pull request build status to Github

I have a pull request trigger for Github in VSTS. I also want to add this trigger to the required checks in Github and show build status on pull request page like below.

enter image description here

I also checked branch protection page on Github but there are no status checks available.

enter image description here

Is it possible to do this in VSTS or do I need to create a PR status server mentioned here ?

Upvotes: 6

Views: 3325

Answers (4)

surya vallabhaneni
surya vallabhaneni

Reputation: 940

From Jenkins, Pull-Request Status can be created/updated from pipeline

script {
    pullRequest.createStatus(status: "success",
                             context: "validate-profiles",
                             description: "Profiles file validated successfully!",
                             targetUrl: "$RUN_DISPLAY_URL")
}

enter image description here

Tons of other things can be done from pipeline avoiding explicit calls to GitHub API

Make a comment on Pull-Request

pullRequest.comment("Your service-profile request is received. Please track ticket progress here: "+ticketData['_links']['web'])

Create & Add Labels to Pull-Request

pullRequest.addLabel(env.TICKET_ID)

Update Title for the Pull-Request

pullRequest.setTitle("["+env.TICKET_ID+"] Profile Review Request for "+env.CHANGE_TARGET)

Upvotes: 0

dahlbyk
dahlbyk

Reputation: 77620

Configuration for enabling the GitHub commit status checks in Azure DevOps seems to have changed.

  1. Ensure Azure Pipelines is installed for your organization or repository
  2. Edit your Azure DevOps Build (Pipeline)
  3. Click on the Get sources step
  4. Under the GitHub configuration, select Report build status
  5. Save (& queue, if you wish) your updated configuration

If someone on the DevOps team sees this, reporting commit status should be enabled by default!

Configure GitHub commit status in Azure DevOps

Upvotes: 3

Ilkay Ilknur
Ilkay Ilknur

Reputation: 913

I checked Advanced settings => Report build status option and VSTS automatically sends commit status to Github.

enter image description here

Upvotes: 3

starian chen-MSFT
starian chen-MSFT

Reputation: 33738

There isn’t such setting in VSTS, you can refer to this workflow to do it:

  1. Get a commit sha
  2. Create a status check context through REST API

Post: https://api.github.com/repos/[owner]/[repository]/statuses/[commit sha]

Body(application/json):

{
  "state": "success",
  "target_url": "XXX",
  "description": "Build verify",
  "context": "continuous-integration/vsts"
}

Then check the related status check in branch protect page:

enter image description here

Note: the target_url can be badge URL (Check Badge enabled in Options of build definition)

  1. Create a build definition to create status through REST API (The same as step 2: change commit sha and body) in VSTS continuous integration (Enable continuous integration) for current commit
  2. Create a build definition to update status of current commit through REST API in VSTS (Enable pull request validation)

Upvotes: 2

Related Questions