TeamCity - get running builds with build parameters - teamcity

I want to get the build parameters of a running build, how can i do that via rest?
I know the following link gets me the current running builds
but how can i get the build parameters for them?
> http://teamcityserver/httpAuth/app/rest/builds?locator=running:true

Once you have the list of running builds you will need to make a call to the URL shown below for each build supplying the relevant ID.
http://teamcityserver/httpAuth/app/rest/builds/id:<BuildIdGoesHere>
This will retrieve the details of the build including the build parameters which you will find in the <properties> node.

Related

Rest api to get sonarqube info from bamboo build or vice versa

Is there any way I can get any sonarqube api which can provide the build number of bamboo or any bamboo api which can give sonarqube info.This would really help.
I have so far tried both side but i am surprised both the system are quite clueless about each other. Why it is not possible that a build which ran sonarqube as as one of it's job doesn't have any information about that. Also neither in sonar it tell which build has actually triggered that sonar execution
(Not sure I understand what exactly you are looking for, perhaps this ...? )
I don't believe you can relate a specific Activity (SonarQube analysis) to a specific build (Bamboo), just project to job.
You must have SonarQube Server configured in Bamboo
When executing your job, you can add these sonar.links optional parameters to the analysis step:
sonar.links.homepage Project home page.
sonar.links.ci Continuous integration.
and
sonar.links.scm Project source repository.
sonar.links.issue Issue tracker.
Maybe also specify sonar.host.url=$SONAR_HOST_URL (where SONAR_HOST_URL is the global setting in Bamboo) in the analysis step parameters.
Those populate the Project Overview page sidebar:
That should provide the links from SonarQube back to the other systems of interest.
If you have properly configured Bamboo, you should see a link in Bamboo to the SonarQube project, post execution.

Cucumber test failed first time build in Jenkins but when run build multiple times build get pass

I am using a cucumber test with multiple features file for testing spring boot project, test run locally passed and when go to Jenkin build it gets failed but when I am trying multiple time build(3-4 times) its get succeed and build pass without doing any changes.
I don't understand what wrong I am doing is there any data related problem or Jenkin configuration problem or multiple feature file problems.
please guide what I am missing?

TeamCity API. Do not run new build if build is already in progress

How to prevent the launch of the build code branch, if the build code from a branch is already in progress?
Build runs through API from JIRA Automation (Send Webhook Request) to:
http://teamcity.url/app/rest/buildQueue?buildTypeId=<buildTypeId>
Request Body:
<build branchName="{{issue.fields.branch}}">
<buildType id="<buildTypeId>"/>
</build>
Problem: since the JIRA does not know anything about whether the build is running or not on the TeamCity, the JIRA starts the build again if rule was executed
TL;DR
I checked and it works
Just create the base configuration which you want to run. Let's say A
Create the configuration B which depends from A as Slapshot dependency with params
Do not run new build if there is a suitable one - checked
Only use successful builds from suitable ones - checked
Run build on the same agent - unchecked
Make build start of faild - both
How it works?
You will trigger the configuration B. B depends from A. B checked that the A already has a build with some branch and commit, so, no need to run one more, so let's finish.
if A has a new commit then the B see that A has changes, so let's start a new Build A, wait for finish.
If A failed then B also will be failed.
p.s. now you should trigger B instead of A.

Get parameters from multiple build to one snapshot dependent build [teamcity]

In Teamcity 9.0.1 I have several builds, which ends up on similar steps, but with different parameters.
In fact, those are servicing steps, not needed by a build to conclude, that build is ok, but they are needed for service, so, currently, they are just running and consuming time.
What I am trying to reach - is move those steps to completely separate build, and invoke it on successful build end trigger. However, I could not figure out - how to pass changes parameters to these newly created build?
Snapshot dependency does not give me level of control I would like to have, as it requires me to define dependency parameters from specific build id, instead of reading them from build, which just ends.
Using artifact dependency by downloading .teamcity/properties/build.finish.gz!** fails with error:
Unknown archive type
and, actually, will oblige me to create additional xml parser
There's nothing built in to trigger builds with custom parameters on a finish-build trigger.
You will have to use the TeamCity REST API / HTTP endpoint to trigger the servicing build with custom parameters - you can pass them as key/value pairs using the following syntax (preferably use HTTPS of course):
http://testuser:testpassword#teamcity.jetbrains.com:8111/httpAuth/action.html?add2Queue=MyBuildConf&name=<full property name1>&value=<value1>&name=<full property name2>&value=<value2>
For further information see the docs.
Implementation-wise you should be able to do what you want in a few lines of powershell as a last step in the triggering build configs - they would have to pass the build parameters you want. If you use this in multiple build configurations I'd move this step into a common template or use a meta-runner.

Prepare property file with bamboo build number while making war using maven

I need to show version number including three figures
1. Using pom version (done)
2. Commit number from Git (done)
3. Build number from Bamboo ( worst part :( )
I tried to make one property file with placeholders as bamboo.properties in my project. I am expecting that when Bamboo prepares the build it will replace those properties and include that file in war. Later I will read those properties and expose to Web Layer.
Am I doing right? Because I need that my other team members should able to make build locally without Bamboo?
bamboo.properties:
bamboo.buildKey=${bamboo.buildKey}
bamboo.buildResultsUrl=${bamboo.buildResultsUrl}
bamboo.buildNumber=${bamboo.buildNumber}
bamboo.buildPlanName=${bamboo.buildPlanName}
bamboo.buildTimeStamp=${bamboo.buildTimeStamp}
Here is how we achieve above after long time.
Pom version
A simple maven property that can be accessed.
Commit id from git
Since in this project we are using git only, there is a maven plugin that gives you information about commit number. With the help of it you can retrieve Git commit id. For details please look for
git-commit-id-plugin
For bamboo there is environment variable that you need to configure in bamboo settings (For me this has done by client as he owns it). But after it we access it in our env as "<bamboo.build.no>"
Thanks

Resources