使用application.properties
中的信息和环境名称生成显示名称。基本上它是这样产生的:"${app.name}-${env.name}-${app.version}"
。您可以在编译之前在Jenkins中添加构建步骤来修改名称和版本。
E.g.我们使用Gant脚本来添加从Mercurial中提取的额外信息以构建应用程序的名称和版本。这是我们的脚本:
// File: scripts/PrepareApplicationProperties.groovy
target(prepareApplicationProperties: "set application properties") {
def buildNumber = metadata.'app.number' = System.getenv('BUILD_NUMBER') ?: "0"
metadata.'app.mercurialRevision' = System.getenv('MERCURIAL_REVISION') ?: "0"
def mercurialRevisionNumber = metadata.'app.mercurialRevisionNumber' = System.getenv('MERCURIAL_REVISION_NUMBER') ?: "0"
metadata.'app.version' = metadata.'app.version' + ".$buildNumber.$mercurialRevisionNumber"
metadata.persist()
}
setDefaultTarget(prepareApplicationProperties)
更通用的解决方案是什么HAKI先生提出: http://mrhaki.blogspot.com.au/2011/02/grails-goodness-one-war-to-rule-them_4229.html,因为他直接操纵web.xml
。
// File: scripts/_Events.groovy
eventWebXmlStart = { webXmlFile ->
ant.echo message: "Change display-name for web.xml"
def tmpWebXmlFile = new File(projectWorkDir, webXmlFile)
ant.replace(file: tmpWebXmlFile, token: "@[email protected]",
value: "${grailsAppName}-${grailsAppVersion}")
}
谢谢你,我想我会尝试一些类似'_Events.groovy'钩选项,也许将Jenkins环境变量添加到字符串中。 – AlejandroVD 2015-02-09 21:09:59