有沒有方法從命令行定義teamcity ['build.number']屬性?我試過了-Pteamcity.build.number = 1,但沒有奏效。如何從命令行定義gradle中的teamcity ['build.number']屬性
我有這個任務的build.gradle文件吧:
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'
}
}
它工作在構建服務器,但它驅動所有的開發商瘋了,因爲我們沒有對我們的機器上安裝的TeamCity做和任何gradle這個命令給了我們一個錯誤:
$ 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
此解決方案不適合我因爲這是因爲這個https://issues.gradle.org/browse/GRADLE-1826。但我改變了hasProperty(「teamcity」)到rootProject.hasProperty(「teamcity」),現在它正在工作。不管怎樣,謝謝你! – MistaGreen