I am new to TeamCity.
I need to create a configuration parameters for build (android).
Configuration parameters should consists from git branch (branch to build), build type and where to push the build (if i choose to push at all).
Example.
How to automatically populate "Build Branch" field with git branches from my repo?
Depending on what is selected in "Build Type" [Release|Debug] how to automatically change what is available for selection in "Make Public" field.
Example:
If "Build Type" is Debug then A and B should be available to select in "Make Public" field.
If "Build Type" is Release then C and D should be available to select in "Make Public" field.
TeamCity version: "TeamCity Professional 2018.1.1 (build 58406)".
First of all, you should use the VCS Roots.
Go to
Create VCS Root
Attach this VCS to your build
General Settings
Version Control Settings
Attach VCS root
Now your project able to build on the different branch
Create the Parameter Build_Type
Click to Spec: Edit
The construction
Debug => A,B
Release => C,D
means if I choose Debug, the real value of the parameter %Build_Type% is A,B
TC hasn't an opportunity to create a depends parameters what you want. But you can use the real value of Build_Type.
The second way is:
User selects the Build_Type and Make_Public.
Run the custom script to determine the needed value and pass it to project.
One more way:
Create a template of builds
Create 2 projects where 1th has one parameter, the second project has another
Related
TeamCity Documentation states:
In the version control settings of the config, make the branch specification:
+:refs/pull/*/merge
But in my VCS Root Card, there is no section named "Branch specification", what should i do ?
Here is my current configuration screen
In order to setup the Branch specification parameter, you need to click on "Show advanced options" at the bottom of the config screen (just above the save button)
Inside this textarea, you can set: +:refs/pull/*/merge
I'm using perforce in my project. I would like to ask, how can I set the build branch in teamcity? Right now if I want to make a build it is taking code from trunk, when I hit the "run" button it is asking me for my username/password/perforce job, I also need to ask me for a branch name. I know that is needs to be set in the build configuration in build parameters.
I'd suggest using the "Run Custom Build" button to achieve it. It's located next to the "Run" button and titled with ellipsis (three dots in a row).
I might be mistaken in case of the particular VCS you're using (Perforce) though, but for me it works pretty good. When you run a custom build you can either specify the value of your %BranchName% parameter (needs to be specified in your VCS' settings) in "Parameters" tab or select a branch in "Changes" tab.
Hope this helps.
i am looking for a way to share build number between multiple build configurations. The goal is to have an global counter of some sort and all build configurations would be incrementing it and use it in its own the build number.
If one of build configurations A has snapshot or artifact dependency on build configuration B, then you can obtain build number from B in A with help of dependency parameter:
%dep.<B id>.build.number%
Where <B id> is id of build configuration B (see buildTypeId parameter in URL).
This solution works for me:
Create Build Configuration. Let say "GenerateBuildNumber", do not attach template. Do not specify any build steps. Click Save.
Edit configuration for your project. Go to "Build Configuration Settings->Dependencies". Click "Add new snapshot dependecy".
Select previously created "GenerateBuildNumber" in "Depend on" section. Uncheck option "Do not run new build if there is a suitable one". Click Save.
Go to "General Settings", clear "Build number format:", click the button on the left side with 3 lines. Select "%dep.YouProjName_GenerateBuildNumber.env.BUILD_NUMBER%". Click Save.
Run your project build. Firstly it should start "GenerateBuildNumber" project then your project with a generated number.
Do the steps 2-4 for every project you want to have unique generated number.
Profit!
I believe the AutoIncrementer plugin should do the trick. It lets you share build numbers between configurations. http://confluence.jetbrains.com/display/TW/Autoincrementer
You can make one Team City project use the build number from another project by following these steps:
Open the TeamCity project configuration's properties for the configuration where you want to import the build number.
Go to the "Dependencies" section.
Add an "Artifact Dependency" and choose the project configuration that you want to get the build number from as the dependent project.
In the "Get artifacts from" field choose "Build with specified build number"
Next to the "Build number" input box there is a button you can click to choose where to get the build number. In this list you should see an option like "dep.bt2.build.number" (the number might not be 2 for your configuration).
AutoIncrementer is good, but now there is a new plugin that has tried to do what some users said they can't do with AutoIncrementer:
http://java.nicholaswilliams.net/TeamCityPlugins/introduction#SharedBuildNumber
It has a UI when you add it to TeamCity, and can also handle the use of dates in the format that you might want to use.
The easiest way by far is to use the variable that gets exposed:
%dep.<build configuration id here>.build.number%
You can use any parameter from the dependency using that variable. If you start typing % in a field with the square box next to it that lets you choose a variable it will pop up with the build configuration id there.
How to set parameter
Step 1: Using IDE to pick up which one you want to use
Step 2: %dep.[B id].build.number% from another project name
How to get parameter
echo %CAPR_number% <-- Parameter Name
Given this structure:
$/TeamProject/
Project A/
Development [Branch] <-- Labeled "v1.0" # latest
Project B/
Development [Branch] <-- new pending v1.0 release
Product A already has a label "v1.0" set on its Development Branch.
But now when I try to label Product B branch with label "v1.0", VS is saying that that label already exists and will be overwritten?
How can this be when the Project A label was set on the Project A branch and has nothing to do with the Project B branches.
Product A and Product B are part of the same system but are released independently as and when they are updated.
Is this a bug or am I missing some step to the process.
I am using the VS Team SCE as I prefer to use a GUI than CLI.
I have read somewhere that a label has scope, surely when you set a label on a folder in VS it sets that folder as the scope, no?
Thanks,
Gary.
In case it helps anyone.
According to http://msdn.microsoft.com/en-us/library/ms181439(v=vs.80).aspx (the vs2010 one does not mention this but it still applies):
Labels created within the graphical user interface are scoped to the root folder of the team project within which they are created. Labels created from the command line are scoped to the longest common path shared by the items specified in the label command.
Not sure why MS have chosen to do this, as you can right-click a branch / folder and select "Apply Label" which is kind of misleading.
Suppose I have a list of changesets 1 to 10. Is it possible to specify that it build till changeset no. 5, instead of building just for a particular changeset or all the changesets 1-10?
I know It's possible to specify a particular version of the files to build, like changesetId,Date,Label,latest and workspace versions. So how do I specify "Build till C5" when triggering a custom build in my application?
Yes, you can do that using the default build process template. In the "Advanced" section of the build process parameters (in the Process tab of the build definition editor), set the "Get Version" parameter to the changeset you want to build (e.g. "C5"). More logically, you would do this in the Queue Build dialog's "Parameters" tab.