TeamCity 8.1.2 REST API: Get the running build of the specified build configuration - teamcity

I'm using TeamCity 8.1.2 REST API and I want to check if there is a running build in my build configuration.
To get builds in a queue I can use the following request:
> http://<tc_address>/app/rest/latest/buildQueue/?locator=buildType:<my_buildTypeId>
It returns the builds in the queue but not the running one.
Accroding to documentation https://confluence.jetbrains.com/display/TCD8/REST+API to get running builds this request can be used:
> http://<tc_address>/app/rest/builds/?locator=buildType:<my_buildTypeId>,running:true
But it returns no builds. I tried
http://<tc_address>/app/rest/builds/?locator=running:true
which returns running builds from other build configuration but the running build from my build configuration is not listed.

Your API call is correct but seems like you are missing some configuration.
Check below setting for the given issue :
-> Go to Build Configuration
-> Edit Configuration Settings
-> General Settings
-> Build options
-> Enable status widget [Check this checkbox]
after that check API call

Related

Update teamcity pipeline in a branch

I have an existing teamcity pipeline which is running fine.
We use teamcity dsl to define the same.
I want to replace this with a new pipeline. I am experimenting with this pipeline in my own branch. When I try and push my change, I see this error
[Retrieve settings, revision: f16566918ecccbe079d02bd3c3689575408a0957] Read build settings from revision f16566918ecccbe079d02bd3c3689575408a0957
[10:01:05] [Read build settings from revision f16566918ecccbe079d02bd3c3689575408a0957] Failed to load build configuration settings from VCS: build configuration config is not found, use current settings from TeamCity server
Internal teamcity experts are asking me to do my development on a test teamcity environment we have.
Is this the only option?
Is there a way I can force teamcity to pick a new dsl based pipeline defined in a branch?

TeamCity - Get Build Server Log | Currently Build

I am using TeamCity build server for my CI process. I have a scenario, where i need to compare my previous and current build log and check for warnings in the code ad if the warnings count in the current is greater than the previous build, we have to fail the build.
I have two build steps namely:
For MS build
A powershell script to compare the builds ( previous build and current build)
I understand we can get the build information using the TeamCity API which is http:// /httpAuth/downloadBuildLog.html?BuildId=<< current build id >>
Is there anyway to get the build log while the build is in running state, and pass on to my second step ?

Configure Multiple SonarQube Instances in a Gradle Build

In our CI environment, we currently have one build server (based on Atlassian Bamboo) and two SonarQube instances (versions 6.0 and 6.5). Initially, our CI server was configured to communicate with the 6.0 SonarQube instance. This has been configured in the /home/bamboo/.gradle/gradle.properties file on our CI server like this:
systemProp.sonar.host.url=<http url of SonarQube 6.0 instance>
systemProp.sonar.login=<username here>
systemProp.sonar.password=<password here>
Now we have another Gradle-based project running on our CI server which shall talk to the new SonarQube 6.5 instance. I tried configuring this but failed all the time.
Things I have done so far:
Added commandline arguments to gradle wrapper command:
I have tried adding -Dsonar.host.url=, -Dsonar.login=, -Dsonar.password= to the Gradle command. As this didn't seem to work, I have also tried to set commandline arguments as SonarQube system properties using -DsystemProp.sonar.host.url=, -DsystemProp.sonar.login=, -DsystemProp.sonar.password=. This didn't work either.
Added properties to the build.gradle file
- Added properties to the build.gradle file like this:
sonarqube {
properties {
property "sonar.host.url", "<http url of SonarQube 6.0 instance>"
property "sonar.login", "<username here>"
property "sonar.password", "<password here>"
...<other SonarQube analysis settings here>...
}
}
In all cases, the CI server talked to the wrong SonarQube instance (6.0). My question is, whether it is possible to configure a single project to talk to another SonarQube instance. As you have seen, we use Gradle 3.2.1 as a build tool. And we are using the org.sonarqube Gradle plugin too.
Thank you for any help.
André
Your first try did not work, because you set the system properties from the commandline, but setting it from the project properties later on resets the system properties to the configured values.
Your second try did not work, because the systemProp.sonar.login syntax is only suppored in gradle.properties files, not via -P commandline project properties.
Your third try did not work because the SonarQube scanner prefers the system property values over the value configured via the DSL, so that one can change what is configured in the build script with the help of local configuration.
You need to set the system properties in your build script manually, this then overwrite what was automatically set from the project property. Using the project gradle.properties file does not work as the user file overwrite the project file. So you need something like System.properties.'sonar.login' = '...' in your build script. You can either hard-code it there, or then use project properties that you can set in your gradle.properties file or via -P parameters.
Besides that, I'd never depend on having any configuration in Gradle User dir on a build server. Most buildservers use build agents that might run on distributed machines, so you would always have to make sure that all build agents are configured the same and so on. I'd always configure in the build setup of the build server the according configuration, either by setting system properties, or environment properties or commandline arguments.
Just my 2ct.

Configuring gitlab with TeamCity

I'm using GitLab CE 9.2.1 df00a75 and TeamCity 2017.1.1 (build 46654) and I need to build next:
When developer open merge request TeamCity should run ESlint and Jest tests and return to gitlab success or failure status.
When I accept merge request TeamCity should build project and deliver it.
What I achieved for now - tests run when open merge request and when I accept merge request tests also runs.
Part of VCS Root config. I think my problem is here →

TeamCity Build Chain configuration

I have a TeamCity project which includes 4 configurations and the build chain needs to look something like this:
Build which can be triggered manually and executes .bat scripts that compiles a bunch of artifacts for the Deploy and TEST to pick up.
Deploy and TEST – Region 1 has an artifact dependency on the Build config.
Deploy and TEST – Region 2 has an artifact dependency on the Build config.
Since I wanted both Region1 and Region2 to run in parallel as soon as Build is successful, I added a Snapshot dependency to Deploy and TEST – Region 1 and Deploy and TEST – Region 2 on Build config
Now I need to configure the Test Status config just to report the failure/success of the previous config (Deploy and TEST configs).
How can this be achieved? Also, do I need to tweak my set up anywhere for the use case I am trying to achieve?
The setup looks correct. To get the build chain status in Test Status configuration, you need to add snapshot dependencies on Deploy and TEST – Region 1 and Deploy and TEST – Region 2 configurations. If any build from the chain fails, Test Status build will also fail with status: "Snapshot dependencies failed:​ .​.​.​ < build configurations names >"
If you add these snapshot dependencies and run Test Status via UI, the whole build chain will be added to the queue. Also you can configure one VCS trigger in Test Status build configuration with option "Trigger on changes in snapshot dependencies". With this options enabled, the whole build chain will be triggered even if changes are detected in dependencies, not in the resulting build.
This article can be helpful.

Resources