开发者

In Grails, how can I append a build number when using 'set-version'

开发者 https://www.devze.com 2023-02-11 03:57 出处:网络
I am using Jenkins (Hudson) with the Grails plugin to do builds as I update svn.I found this example script that allows you to incorporate a build number from an env var:

I am using Jenkins (Hudson) with the Grails plugin to do builds as I update svn. I found this example script that allows you to incorporate a build number from an env var:

set-version 1.1.0.${env['BUILD_NUMBER']}

But as you see, the prefix is hard-coded. I'd like to use the version number set in the application.properties file. How can I do something like:

set-version ${app.version}.${env['BUILD_NUMBER']}
开发者_如何学JAVA

Have tried a variety of scopes/syntax to no avail.


It is not possible out of the box. Jenkins or specifically the Grails plugin does not read the content of the application.properties file and hence the existing application version is not available as a variable.

You might want to consider writing a custom script in your application (like append-version) that will read application.properties and append the value passed in. You can call the existing set-version script modifying the argument.

I have also created a simple script that should do the job:

includeTargets << grailsScript("Init")

target(main: "Append a string to the existing version number") {
    depends(checkVersion, parseArguments)

    def newVersion = metadata.'app.version' + '-' + args
    metadata.'app.version' = newVersion
    metadata.persist()
}

setDefaultTarget(main)
0

精彩评论

暂无评论...
验证码 换一张
取 消