eventCreateWarStart = { warName, stagingDir ->
def unknownValue = 'UNKNOWN'
def buildNumberEnvironment = 'BUILD_NUMBER'
def scmRevisionEnvironment = 'GIT_COMMIT'
def buildNumberProperty = 'build.number'
def scmRevisionProperty = 'build.revision'
def buildNumber = System.getenv(buildNumberEnvironment) (1)
if( !buildNumber ) { (2)
buildNumber = System.getProperty(buildNumberProperty, unknownValue)
}
def scmRevision = System.getenv(scmRevisionEnvironment)
if( !scmRevision ) {
scmRevision = System.getProperty(scmRevisionProperty, unknownValue)
}
ant.propertyfile(file:"${stagingDir}/WEB-INF/classes/application.properties") {
entry(key:'app.version.buildNumber', value: buildNumber) (3)
}
ant.manifest(file: "${stagingDir}/META-INF/MANIFEST.MF", mode: "update") {
attribute(name: "Build-Time", value: new Date()) (4)
section(name: "Grails Application") { (5)
attribute(name: "Implementation-Build-Number", value: buildNumber)
attribute(name: "Implementation-SCM-Revision", value: scmRevision)
}
}
}