Is there a way to define teamcity[‘build.number’] property from command line? I tried -Pteamcity.build.number=1 but it didn’t work.
I have a build.gradle file with this task in it:
distTar {
baseName = project.name+'.'+
project.version+'.'+
System.getProperty("system.rnf.brach_name")+'.'+
teamcity['build.number']+'.'+
teamcity['build.vcs.number.1']
archiveName = baseName+'.tar'
into(baseName) {
from '.'
include 'config/*'
include 'run-script/*.sh'
}
}
It works on the build server, but it drives all the developers crazy, because we don’t have teamcity installed on our machines, and any gradle command gives us an error:
$ gradle tasks
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/work/myproject/build.gradle' line: 31
* What went wrong:
A problem occurred evaluating root project 'myproject'.
> Could not find property 'teamcity' on task ':MyProject:distTar'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
It comes from TeamCity, the software on our build server. But I don’t think it matters what the strings are. How can I define something from the command line or environment variable or grade.properties, that will be accessible by the above cited distTar task as "teamcity[‘build.number’], or x[‘y.z’] ? It seams that I can do: -Py=1 or maybe even -Py.z=2, but I can’t find how to make the “x[‘y.z’]”
We tried that already. It doesn’t work. It does work only in our machine where there’s no teamcity, but it doesn’t enter the if block even on the temacity machine.
Currently I could only do this hack:
in build.gradle I added:
if (hasProperty("dev")) {
apply from: 'teamcity.gradle'
}
I made a few errors there: 1) Logic should have been inverted. 2) I was not supposed to look at project.ext but only project for the teamcity property.
if (project.hasProperty("teamcity"))
{
// We are being built by TeamCity.
version = "1.0." + teamcity['build.number']
releaseURL = "http://bla.bla.co.za:8081/nexus/content/repositories/releases"
}
else
{
// We are being built from the IDE or commandline.
version = "1.0-SNAPSHOT"
releaseURL = "http://bla.bla.co.za:8081/nexus/content/repositories/snapshots"
}