Sudheej
Sudheej

Reputation: 2029

Teamcity perform GIT Checkout

Team city agent which is currently performing the build does not have 'git' installed its a linux box. I cannot have git installed there.

Is there a native method in teamcity which can support the below in build step :

git checkout -b %dynamicversion%

Upvotes: 6

Views: 1717

Answers (2)

danglingpointer
danglingpointer

Reputation: 4930

Answer to your question. You need to make sure git package is installed in the linux box, in order to do that you can do following things.

I guess your using tracks in your Team city agent to run the linux.

If you use makefile or script, you can add a target which is call prepare-dev or "anymeaningfull_name" in that you can try to install the git package as prerequisites.

git checkout -b %dynamicversion%

What I understood, you want to checkout the latest branch which has buildversion tag.

You can create ts.native.ini file add the dependecy package,

suite: precise
mirror: http://xx.archive.ubuntu.com/ubuntu
components: main restricted universe
packages: mtools devscripts gcc make git libgnutls28-dev libboost-test-dev sudo e2fsprogs
prepare: make prepare-dev
preparefiles: Makefile

Once after doing this you can add target. You can use it in your script.

#!/bin/sh

set -e

if [ "$(whoami)" != "root" ]; then
    echo "Please run as root"
    exit 1
fi
git clean -xfd
trap "$TRACKS -u" EXIT

_mkdebs()
{
    export TRACKS_INIFILE=ts.trusty(native).ini 
    $TRACKS -b -- make mkdebs CCACHE_DIR=$CCACHE_DIR
}

You can add ts.native.ini track file in your teamcity agent so that it will install all the prerequsities which is needed.

Upvotes: 0

Didier Aupest
Didier Aupest

Reputation: 3377

Inside the VCS Root settings, you can set the Branch Specification. The Branch Specification will allow you to run a specific branch (ie: +:feature/*)

Then a combo box will appear on the top of your project, in order to select your project.

If the branch to build depends of something in your code, you can do multiple configurations, with dependencies, and triggering using API.

Build 1

Build on <default> where you get the branch to run. API Call on teamcity which will call Build 2 with the parameter branch set to the specified value:

# RunSpecificBranch.ps1
# PowerShell: Run Build Configuration on a specific branch
Param(
     [Parameter(Mandatory=$true)][string]$branchName,
     [Parameter(Mandatory=$true)][string]$BuildToRun
)
Begin
{
    $TCUrl = "http://&lt;teamcityURL&gt;/httpAuth/app/rest/buildQueue"
    Execute-HTTPPostCommand $TCUrl "<build branchName=""$branchName""><buildType id=""$buildToRun""/></build>"
}

And Execute this script like: RunSpecificBranch.ps1 -branchName: feature/ME/AwesomeFeature -buildToRun: Project_SubProject_SpecificBuildOnBranch inside your build Step.

The checkout of the branch will be done by the server before running the build configuration Project_SubProject_SpecificBuildOnBranch

Build 2

Specified to run on multiple branches as specified bellow, you will do here your custom logic that you need.

Upvotes: 1

Related Questions