我有发布应用程序的Jenkins CI管道。此过程的工作方式是,人员触发要发布的发布作业。此作业通过gradle依赖性命令检查所有项目依赖性。对于快照发布作业的所有依赖项,都会自动触发。
发布作业只需升级lib /应用程序版本并将其部署在 Artifact 中。
如何自动将SNAPSHOT依赖版本升级到Gradle中的发布版本?
我的build.gradle文件如下所示:
Properties versions = new Properties()
versions.load(new FileInputStream(rootProject.projectDir.path + "/version.properties"))
dependencies {
compile("projectA:${versions.projectAVersion}")
compile("projectB:${versions.projectBVersion}")
}
和version.properties文件
projectAVersion=1.1.0-SNAPSHOT
projectBVersion=1.1.0-SNAPSHOT
实际上,我正在寻找类似于Maven版本插件的东西。
编辑
实际上,我只需要Gradle中的Maven版本插件(版本:use-releases和版本:use-next-releases)功能。
最佳答案
您的问题我不清楚。据我了解,您需要在每次构建后动态更新版本值。
您可以做的就是获取属性值。删除-SNAPSHOT。每次构建后以增量方式更新1.1.0。像1.1.1、1.1.2等。
这可以通过
task testing {
Properties props = new Properties()
//getting and loading the property file
//Give proper path to file
File propsFile = new File('version.properties')
props.load(propsFile.newDataInputStream())
//Now strip of -SNAPSHOT and get the last digit and increment it by 1
Integer rand = props.getProperty('lastDigit').toInteger()+1
String variable=rand.toString()
//Append -SNAPSHOT with 'variable and set the property
props.setProperty('version',variable)
props.store(propsFile.newWriter(), null)
}
如果我对您的问题的理解是正确的,那么它将起作用。
关于gradle - Gradle-自动更新依赖版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45214947/