Reputation: 1426
I have a gradle build script as below:
buildscript {
repositories {
//Some repo
}
dependencies {
classpath "com.palantir.gradle.gitversion:gradle-git-version:0.8.0"
}
}
}
apply plugin: 'com.palantir.git-version'
version gitVersion()
I would like to update TeamCity build number
with the value of version
from the gitVersion()
function. Is there anyway to do that?
I know in Maven world, for TeamCity to pick-up the version in pom.xml
file, I can specify TeamCity build number equal to %maven.project.version%
. But how to achieve the same thing with Gradle?
An attempt:
Also, I thought of a solution to create a Gradle Exec task to update TeamCity build number via Service Message (doc here):
task updateTeamCityBuildNumber(type: Exec) {
x=version
echo $x
echo "##teamcity[setParameter name='buildNumber' value='${x}']"
}
But I got this error:
Could not set unknown property 'x' for task ':updateTeamCityBuildNumber' of type org.gradle.api.tasks.Exec
So another question on this direction is that how do I pass the variable version
into the Gradle Exec task and refer to it in the "echo" statement below?
(My TeamCity build agent is Linux)
Thanks and let me know if you need more details
Upvotes: 0
Views: 2102
Reputation: 11
As of TeamCity Professional 2017.2 (build 50574) original variant
println "##teamcity[setParameter name='buildNumber' value='${x}']"
is working again.
Upvotes: 0