Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSTS badge instructions no longer work for Azure DevOps #2082

Closed
MichaelMauderer opened this issue Sep 15, 2018 · 7 comments
Closed

VSTS badge instructions no longer work for Azure DevOps #2082

MichaelMauderer opened this issue Sep 15, 2018 · 7 comments
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas

Comments

@MichaelMauderer
Copy link

When trying to create a badge for Azure DevOps I was trying to follow the instructions for VSTS, but it seems that the ULR scheme has changed and the project ID and is no longer exposed (or a different name-based identifier is used instead).

Example for the current badge url scheme:

https://colour-science.visualstudio.com/Colour/_apis/build/status/colour-science.colour?branchName=develop
                                                                  |--------------------|
                                                                  |----Project ID?-----|
@chris48s
Copy link
Member

Thanks for raising this. I've never used Visual Studio Team Services, so this is a bit hard for me to debug/advise. Working backwards from our example, it does seem to be valid to call a URL like:

https://larsbrinkhoff.visualstudio.com/953a34b9-5966-4923-a48a-c41874cfb5f5/_apis/build/status/1

@Thilas - you've recently made a useful contribution to the Visual Studio integrations which uses a similar URL pattern to extract data from visualstudio.com . Are you able to provide advice on how to find the correct 'project id' and 'build definition id' to make this badge?

@chris48s chris48s added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Sep 16, 2018
@Thilas
Copy link
Contributor

Thilas commented Sep 16, 2018

To my understanding, the project guid is expected instead of its name when getting a badge from the "public" API (i.e. that does not require any authentication).

@MichaelMauderer, the url you mentioned is using the "private" API therefore accept the project name. But for the shield.io badge, you have to find the guid of your project which is the only one accepted here. You can get it using VSTS api from a browser where you already are authenticated:

https://colour-science.visualstudio.com/_apis/projects/Colour

Look at the id property returned.

FYI:

https://colour-science.visualstudio.com/Colour/_apis/build/status/colour-science.colour?branchName=develop
  • "colour-science" = team name
  • "Colour" = project name
  • "colour-science.colour" = build name, useless here

@MichaelMauderer
Copy link
Author

Ah yes, that api call showed the correct id/giud. Thanks!

@chris48s
Copy link
Member

Thanks for helping out here @Thilas 👍

Do you think we need to change the documentation?

This is the current help we provide:

const visualStudioTeamServicesBuildDoc = `
<p>
To obtain your own badge, you will first need to enable badges for your
project:
</p>
<img
src="https://cloud.githubusercontent.com/assets/6189336/11894616/be744ab4-a578-11e5-9e44-0c32a7836b3b.png"
alt="Go to your builds, click General, then check Badge enabled." />
<p>
Then, click “Show url…” to reveal the URL of the default badge. In that URL,
you will need to extract three pieces of information: <code>TEAM_NAME</code>,
<code>PROJECT_ID</code> and <code>BUILD_DEFINITION_ID</code>.
</p>
<img
src="https://cloud.githubusercontent.com/assets/6189336/11629345/f4eb0d78-9cf7-11e5-8d83-ca9fd895fcea.png"
alt="TEAM_NAME is just after the https:// part, PROJECT_ID is after definitions/, BUILD_DEFINITION_ID is after that.">
<p>
Your badge will then have the form
<code>https://img.shields.io/vso/build/TEAM_NAME/PROJECT_ID/BUILD_DEFINITION_ID</code>.
</p>
<p>
Optionally, you can specify a named branch
<code>https://img.shields.io/vso/build/TEAM_NAME/PROJECT_ID/BUILD_DEFINITION_ID/NAMED_BRANCH</code>.
</p>
`

@Thilas
Copy link
Contributor

Thilas commented Sep 24, 2018

@chris48s, I'll try to find some time for this. There's one thing I'm not comfortable with though, it's that for now I don't fully understand what inputs are expected by VSTS API: it's like there was multiple behaviors in VSTS depending on how old are your build/release definitions... So I have to figure this out first.

@calebcartwright
Copy link
Member

calebcartwright commented Oct 12, 2018

Probably also worth nothing that as part of the rebrand to Azure DevOps that there is a new URL used to access (https://dev.azure.com/account-name/project-name/…)

Folks that had VSTS prior to the re-brand can still choose to use the old url format (for the foreseeable future) or they can switch to the new one (which will support redirects from the old url to the new for the forseeable future). However, net-new accounts that are created will all be using the new url, details can be found here

There's also a new build status badge url.

I believe with these new APIs you have the option to use the project name (instead of GUID) as well as the definition name/path (instead of the definition Id).

For example here is the url to the status badge for one of my builds in a public project: https://dev.azure.com/swellaby/opensource/_apis/build/status/captain-githook/captain-githook-PR-Linux?branchName=master&label=linux%20build

And I think the corresponding API call to get the latest build is:
https://dev.azure.com/account-name/project-name/_apis/build/latest/definition-path/ , docs here

Corresponding API call for my definition linked above:
https://dev.azure.com/swellaby/opensource/_apis/build/latest/captain-githook/captain-githook-PR-linux

@Thilas
Copy link
Contributor

Thilas commented Oct 21, 2018

As requested, here is a PR (#2206) that renames VSTS service to Azure DevOps (and uses the new URLs). It also updates its documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas
Projects
None yet
Development

No branches or pull requests

4 participants