Description
Concourse is both a self-hosted and a SaaS CI solution. It has a built-in badge server, but unfortunately it only allows one badge style, which is flat.
Pipelines
If a pipeline (Concourse term which refers to a series to tasks) is set to public, a JSON API is exposed at {{concourse-url}}/api/v1/teams/{{team-name}}/pipelines/{{pipeline-name}}/jobs.
[ {
"id": 3,
"name": "test",
"pipeline_name": "build",
"team_name": "openusercss",
"next_build": null,
"finished_build": {
"id": 37,
"team_name": "openusercss",
"name": "18",
"status": "failed",
"job_name": "test",
"api_url": "/api/v1/builds/37",
"pipeline_name": "build",
"start_time": 1519336819,
"end_time": 1519337102
},
"inputs": [ {
"name": "repo",
"resource": "repo",
"trigger": true
} ],
"outputs": [],
"groups": []
}, {
"id": 4,
"name": "approve",
"pipeline_name": "build",
"team_name": "openusercss",
"next_build": null,
"finished_build": {
"id": 19,
"team_name": "openusercss",
"name": "2",
"status": "succeeded",
"job_name": "approve",
"api_url": "/api/v1/builds/19",
"pipeline_name": "build",
"start_time": 1518882062,
"end_time": 1518882890
},
"inputs": [ {
"name": "repo",
"resource": "repo",
"passed": [ "test" ],
"trigger": true
} ],
"outputs": [],
"groups": []
} ]
The pipeline only succeeds if all finished_build.status items are "succeeded". Thus, the badge in the above example would show build | failed.
In my opinion and based on the guidelines, the shields.io URL for the badge should be /concourse/{{scheme}}/{{concourse-url}}/{{team-name}}/pipeline/{{pipeline-name}}.svg
If
team-nameis missing, it should be replaced with "main", which is the default team name in Concourse. Based on my current knowledge, it's not possible for a user not to be a member of a team.
Individual builds
If a build is set to public, a JSON API is exposed at {{concourse-url}}/api/v1/builds/{{id}}.
{
"id": 37,
"team_name": "openusercss",
"name": "18",
"status": "failed",
"job_name": "test",
"api_url": "/api/v1/builds/37",
"pipeline_name": "build",
"start_time": 1519336819,
"end_time": 1519337102
}
The build succeeds if "status" is "succeeded".
In my opinion and based on the guidelines, the shields.io URL for the badge should be /concourse/{{scheme}}/{{concourse-url}}/build/{{build-id}}.svg
Comments
There's potentially other uses of the API as well, like counting builds and last build time. Here are a couple of routes that may be of interest (for the sake of the examples, I'm linking my own instance of Concourse, but these work for all up-to-date installs of the service):
https://concourse.decentm.com/api/v1/builds
https://concourse.decentm.com/api/v1/teams/openusercss/pipelines
https://concourse.decentm.com/api/v1/teams
https://concourse.decentm.com/api/v1/teams/openusercss/pipelines/pull-request
https://concourse.decentm.com/api/v1/teams/openusercss/pipelines/pull-request/jobs