- To obtain your own badge, you will first need to enable badges for your
- project:
+ To obtain your own badge, you need to get 3 pieces of information:
+ ORGANIZATION, PROJECT_ID and DEFINITION_ID.
+
+
+ First, you need to edit your build definition and look at the url:
+ src="https://user-images.githubusercontent.com/3749820/47259976-e2d9ec80-d4b2-11e8-92cc-7c81089a7a2c.png"
+ alt="ORGANIZATION is after the dev.azure.com part, PROJECT_NAME is right after that, DEFINITION_ID is at the end after the id= part." />
- Then, click “Show url…” to reveal the URL of the default badge. In that URL,
- you will need to extract three pieces of information: TEAM_NAME,
- PROJECT_ID and BUILD_DEFINITION_ID.
+ Then, you can get the PROJECT_ID from the PROJECT_NAME using Azure DevOps REST API.
+ Just access to: https://dev.azure.com/ORGANIZATION/_apis/projects/PROJECT_NAME.
+ src="https://user-images.githubusercontent.com/3749820/47266325-1d846900-d535-11e8-9211-2ee72fb91877.png"
+ alt="PROJECT_ID is in the id property of the API response." />
- Your badge will then have the form
- https://img.shields.io/vso/build/TEAM_NAME/PROJECT_ID/BUILD_DEFINITION_ID.
+ Your badge will then have the form:
+ https://img.shields.io/vso/build/ORGANIZATION/PROJECT_ID/DEFINITION_ID.svg.
- Optionally, you can specify a named branch
- https://img.shields.io/vso/build/TEAM_NAME/PROJECT_ID/BUILD_DEFINITION_ID/NAMED_BRANCH.
+ Optionally, you can specify a named branch:
+ https://img.shields.io/vso/build/ORGANIZATION/PROJECT_ID/DEFINITION_ID/NAMED_BRANCH.svg.
- To obtain your own badge, you will first need to enable badges on your release definition.
+ To obtain your own badge, you need to get 4 pieces of information:
+ ORGANIZATION, PROJECT_ID, DEFINITION_ID and ENVIRONMENT_ID.
- Your badge will then have the form
- https://img.shields.io/vso/release/TEAM_NAME/PROJECT_ID/RELEASE_DEFINITION_ID/ENVIRONMENT_ID.
+ First, you need to enable badges for each required environments in the options of your release definition.
+ Once you have save the change, look at badge url:
+
+
+
+ Your badge will then have the form:
+ https://img.shields.io/vso/release/ORGANIZATION/PROJECT_ID/DEFINITION_ID/ENVIRONMENT_ID.svg.
`
@@ -182,16 +192,16 @@ const allBadgeExamples = [
previewUrl: '/codeship/d6c1ddd0-16a3-0132-5f85-2e35c05e22b1/master.svg',
},
{
- title: 'Visual Studio Team Services builds',
+ title: 'Azure DevOps builds',
previewUrl:
- '/vso/build/larsbrinkhoff/953a34b9-5966-4923-a48a-c41874cfb5f5/1.svg',
- documentation: visualStudioTeamServicesBuildDoc,
+ '/vso/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.svg',
+ documentation: azureDevOpsBuildDoc,
},
{
- title: 'Visual Studio Team Services releases',
+ title: 'Azure DevOps releases',
previewUrl:
- '/vso/release/larsbrinkhoff/953a34b9-5966-4923-a48a-c41874cfb5f5/1/2.svg',
- documentation: visualStudioTeamServicesReleaseDoc,
+ '/vso/release/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/1/1.svg',
+ documentation: azureDevOpsReleaseDoc,
},
{
title: 'Jenkins',
diff --git a/services/vso/vso.service.js b/services/vso/vso.service.js
index 11fffe2e8c..737d280ead 100644
--- a/services/vso/vso.service.js
+++ b/services/vso/vso.service.js
@@ -33,34 +33,36 @@ const fetchVstsBadge = (request, url, badgeData, sendBadge, format) => {
module.exports = class Vso extends LegacyService {
static registerLegacyRouteHandler({ camp, cache }) {
- // For Visual Studio Team Services builds.
+ // For Azure DevOps builds.
camp.route(
/^\/vso\/build\/([^/]+)\/([^/]+)\/([^/]+)(?:\/(.+))?\.(svg|png|gif|jpg|json)$/,
cache((data, match, sendBadge, request) => {
- const name = match[1] // User name
- const project = match[2] // Project ID, e.g. 953a34b9-5966-4923-a48a-c41874cfb5f5
- const build = match[3] // Build definition ID, e.g. 1
- const branch = match[4]
+ // Microsoft documentation: https://docs.microsoft.com/en-us/rest/api/vsts/build/status/get
+ const organization = match[1] // The name (string) of the Azure DevOps organization.
+ const projectId = match[2] // The ID (uuid) of the project.
+ const definitionId = match[3] // The ID (int) of the definition.
+ const branchName = match[4] // The name (string) of the branch.
const format = match[5]
- let url = `https://${name}.visualstudio.com/${project}/_apis/build/status/${build}`
- if (branch != null) {
- url += `?branchName=${branch}`
+ let url = `https://dev.azure.com/${organization}/${projectId}/_apis/build/status/${definitionId}`
+ if (branchName != null) {
+ url += `?branchName=${branchName}`
}
const badgeData = getBadgeData('build', data)
fetchVstsBadge(request, url, badgeData, sendBadge, format)
})
)
- // For Visual Studio Team Services releases.
+ // For Azure DevOps releases.
camp.route(
/^\/vso\/release\/([^/]+)\/([^/]+)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,
cache((data, match, sendBadge, request) => {
- const name = match[1] // User name
- const project = match[2] // Project ID, e.g. 953a34b9-5966-4923-a48a-c41874cfb5f5
- const release = match[3] // Release definition ID, e.g. 1
- const environment = match[4] // Environment ID, e.g. 1
+ // Microsoft documentation: ?
+ const organization = match[1] // The name (string) of the Azure DevOps organization.
+ const projectId = match[2] // The ID (uuid) of the project.
+ const definitionId = match[3] // The ID (int) of the definition.
+ const environmentId = match[4] // The ID (int) of the release environment.
const format = match[5]
- const url = `https://${name}.vsrm.visualstudio.com/_apis/public/release/badge/${project}/${release}/${environment}`
+ const url = `https://vsrm.dev.azure.com/${organization}/_apis/public/Release/badge/${projectId}/${definitionId}/${environmentId}`
const badgeData = getBadgeData('deployment', data)
fetchVstsBadge(request, url, badgeData, sendBadge, format)
})
diff --git a/services/vso/vso.tester.js b/services/vso/vso.tester.js
index fe6eb2473d..6f856f47aa 100644
--- a/services/vso/vso.tester.js
+++ b/services/vso/vso.tester.js
@@ -2,7 +2,8 @@
const Joi = require('joi')
const ServiceTester = require('../service-tester')
-const { isBuildStatus } = require('../test-validators')
+
+const isValidStatus = Joi.equal('passing', 'failing')
const t = new ServiceTester({
id: 'vso',
@@ -10,23 +11,25 @@ const t = new ServiceTester({
})
module.exports = t
+// https://dev.azure.com/totodem/Shields.io is a public Azure DevOps project solely created for Shield.io testing
+
// Builds
t.create('build status on default branch')
- .get('/build/devdiv/0bdbc590-a062-4c3f-b0f6-9383f67865ee/7716.json')
+ .get('/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
- value: isBuildStatus,
+ value: isValidStatus,
})
)
t.create('build status on named branch')
- .get('/build/devdiv/0bdbc590-a062-4c3f-b0f6-9383f67865ee/7716/master.json')
+ .get('/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'build',
- value: isBuildStatus,
+ value: isValidStatus,
})
)
@@ -42,37 +45,13 @@ t.create('build status with connection error')
// Releases
t.create('release status is succeeded')
- .get('/release/devdiv/0bdbc590-a062-4c3f-b0f6-9383f67865ee/77/16.json')
- .intercept(nock =>
- nock('https://devdiv.vsrm.visualstudio.com')
- .get(
- '/_apis/public/release/badge/0bdbc590-a062-4c3f-b0f6-9383f67865ee/77/16'
- )
- .reply(200, '')
+ .get('/release/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/1/1.json')
+ .expectJSONTypes(
+ Joi.object().keys({
+ name: 'deployment',
+ value: isValidStatus,
+ })
)
- .expectJSON({ name: 'deployment', value: 'passing' })
-
-t.create('release status is partially succeeded')
- .get('/release/devdiv/0bdbc590-a062-4c3f-b0f6-9383f67865ee/77/16.json')
- .intercept(nock =>
- nock('https://devdiv.vsrm.visualstudio.com')
- .get(
- '/_apis/public/release/badge/0bdbc590-a062-4c3f-b0f6-9383f67865ee/77/16'
- )
- .reply(200, '')
- )
- .expectJSON({ name: 'deployment', value: 'passing' })
-
-t.create('release status is failed')
- .get('/release/devdiv/0bdbc590-a062-4c3f-b0f6-9383f67865ee/77/16.json')
- .intercept(nock =>
- nock('https://devdiv.vsrm.visualstudio.com')
- .get(
- '/_apis/public/release/badge/0bdbc590-a062-4c3f-b0f6-9383f67865ee/77/16'
- )
- .reply(200, '')
- )
- .expectJSON({ name: 'deployment', value: 'failing' })
t.create('release status on unknown repo')
.get('/release/this-repo/does-not-exist/1/2.json')