I have a TeamCity project which includes 4 configurations in the build chain like this.
|----> Build A -|
Prebuild-| |----> Test Results
|----> Build B -|
In the Prebuild configuration based on tags in the Pull Requests I set a variable build which can be "A" or "B" or "A,B". Based on this I need to start just A or just B or both.
Do you know if this is possible?
Related
I have a build chain with two jobs: B depends on A. B needs to get a build counter from A.
dep.btID.property name could share parameters from A to B.
However, the btID is dynamic create by git for each branch
I have add following to build steps of B(bash):
ABuildID=dep.dev_branch_A.env.BUILD_NUMBER
echo '%$ABuildID%'
or
echo '%${ABuildID}%'
It will lead to no compatible agent
Following could work however, I need to adapt to all branchs
echo '%dep.dev_branch_A.env.BUILD_NUMBER%'
Is there any way in TeamCity 9 to pass a build configuration parameter with dynamic btID from a project A to its dependency (in the same build chain)?
---------------------Update after finding the solution, hope it will help someone in the future------------------------
I have found a solution by request last successful build of projectA via rest api.
In bash:
curl -s https://teamcity_host_name/guestAuth/app/rest/buildTypes/dev_branch_A/builds?status=SUCCESS&state=finished&count=1
The response will provide the many parameter of project_A, build number is included
Please find introduction of teamcity rest API:
https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-URLStructure
Thanks Niraj Gajjar for the answser
You have add projectA in ProjectB as either Snapshot Dependency or Artifact Depedency ( for that go to Dependencies from left panel menu)
After that you can use build counter of ProjectA like
%dep.ProjectA.build.counter%
or
echo %dep.ProjectA.build.counter%
I have 2 repos, A and B, which both have a build configuration in TeamCity.
Changes in repo A can impact repo B. When a PR is tested on repo A (say branch R), I want to be able to start another teamcity job that tests repo B and will know about branch R. More specifically, A runs on R, B runs on Master, B has a build step that requires R as an argument for a command. In teamcity, the build config for B is a snapshot dependency for the build config of A.
This other answer showed me how to pass parameters to snapshot dependencies: Passing an environment variable (parameter) to dependency project in TeamCity
However, I can't pass the branch name like %teamcity.build.branch% because the documentation specifies:
Note that the values of the reverse.dep. parameters are pushed to the
dependency builds "as is", without reference resolution. %-references,
if any, will be resolved in the context of the build where the
parameters are pushed to.
from:
https://confluence.jetbrains.com/display/TCD9/Predefined+Build+Parameters#PredefinedBuildParameters-OverridingDependenciesProperties
You can use a finish build trigger for B and make sure the trigger can use the same branch R.
Wait for a successful build in: A
Branch filter:
+:R
We have a build chain setup using teamcity 2017.2.
It looks like the following
A -> B
A:
generates a version number using gitversion
has a VCS root defined
uses gitversion command line to define a version number
B:
sets its version number to the same as A using a dependency proprty
has a snapshot dependency on A with the following settings
Do not run new build if there is a suitable one
Only use successful builds from suitable ones
On failed dependency: cancel build
On failed to start/canceled dependency: make build failed to start
When I make a commit and run B it will trigger A and then B will run, teamcity will show the pending change of the commit that I just made.
However if B fails for whatever reason (and A succeeds) when I rerun B it will rerun for the same commit but the pending changes will be empty. The same also happens if I just want to rerun a previous successful build of B.
The reason this matters is that I'm using the teamcity api to pull a list of changes for a build and passing that off to my deployment tool.
I've tried enabling "Show changes for snapshot dependencies in B" but that did not seem to have an effect
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.
We are using TeamCity 9 and we have defined build configuration looks like:
--> unit tests ---------|
^ ˇ
compile ->+-> integration tests ->+--> deploy
ˇ ^
--> acceptance tests ---|
Dependencies between build are defined as Snapshot dependency (documentation). All tests builds are running in parallel, but I need to define order because integration test needs more time than others so it'll be good to run this test build first.
It's possible to define order or priorities for each build in chain?
Order of builds (waiting mechanism) can be managed by using the build feature named shared resources.
See page # Jetbrains :::
https://confluence.jetbrains.com/display/TCD9/Shared+Resources