Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Buildmaster CI Badge for pipeline step ?
-
Hello
I am using Gitlab CE and successfully display the build step on it.
there I am looking to display badge for the pipeline steps.Is it possible ?
I am looking for displaying something like that on Gitlab,
<build badge> | <integration badge> | <preprod badge> | <prod badge>
Thanks
-
This sounds like a nice idea, and I think something we could implement easily. Of course, figuring out the new specifications / documentation is always the hard part I think :)
How might you suggest changing the CI Status Badges we have now?
I'm envisioning adding in a querystring parameter for
Stage
or something? If you could suggest us how to change the docs / API, that would go a long way in helping us get this implemented :D
-
@atripp said in Buildmaster CI Badge for pipeline step ?:
I'm envisioning adding in a querystring parameter for Stage or something
This should work.
In Gitlab, the definition of the badge would be (for the img part)
https://buildmaster.domain.local/api/ci-badges/image?Key=<API_KEY>&$CommitId=%{commit_sha}&stage=Integration
and it would give a CI badge with the current status of the pipeline stage of the build for which $commitId = {commit_sha}
However, the CI badge text has to be dynamic (3 first characters of stage value seems good enough for me)2 variables are needed in the query string:
- One to set the application to look for ($CommitId)
- One for the stage for which we want the status
Passing one variable to the query string ($commitId in the exemple) will still work in the same way
For beginners
$CommitId is the value of CommitHash (- {commit_sha} from Gitlab -) assign to a variable at the build level
at the inital pipeline stage.Example with Gitlab
GitLab::Get-Source global::GitLab ( Namespace: $Namespace, Project: $Project, Branch: $Branch, PreserveLastModified: true, CommitHash => $commit ); Set-BuildVariable CommitId ( Value: $commit );
This will work for all kind of source repository I think
-
Thanks! Cool "badge site" (shields.io) that you use for the status image like this
NIce ideas, but a couple concerns; currently we use
ApplicationName
as the querystring parameter, which then searches for the current active build or that application.To be able to use
$CommitId
, it would make it more complicated. It would mean we would need to find a build with a variable named$CommitId
and with that value. And at this point, then, we could just allow any number of build variables to be used, which might be nice. $Branch for example.But a concern is performance. That could be a lot of variables to search, so having an ApplicationName filter would be important (build variables are indexed by application Id); it could still be hundreds of thousands of records rows search even in one application.
We could limit it to active builds, which would reduce searching by many orders of magnitudes and be not a problem.
-
In my opinion, using $ApplicationName is not possible, at least for Gitlab
Indeed from GitLab ref, we read :
The URL a badge points to, as well as the image URL, can contain placeholders which will be evaluated when displaying the badge. The following placeholders are available: * %{project_path}: Path of a project including the parent groups * %{project_id}: Database ID associated with a project * %{default_branch}: Default branch name configured for a project’s repository * %{commit_sha}: ID of the most recent commit to the default branch of a project’s repository
As %{project_path} is different from $ApplicationName if the project is defined in a group, the only link between the gitlab project and the builmaster application is the commit_sha var.
I think you just need to add stage as querystring and make the search for the result of the pipeline named stage for which exists an active build variable ($commitId in my example) with a value of commit_sha.
- and $commitId has to be unique over all BuidMaster.
Actually, it is not possible to get more variables (ideally %{project_path} at the GitLab::Get-source step.
The filter would be then better (Filter for project_path+ commitid + stage), but this is still a build variable and not an implicit variable like $ApplicationNameI don't know if there a better way because I have just started to use Gitlab.