4
votes

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 ?

4
Have you had any luck setting up web hooks or services?Mike Tung
There is a VSTS webhook in Github repository and VSTS initiates builds for PRs using this webhook right now. I also added status events to the webhook but nothing changed.İlkay İlknur
did you check logs on VSTS? maybe it's connection?Mike Tung

4 Answers

3
votes

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

enter image description here

2
votes

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

0
votes

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)
0
votes

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)