jenkins the definitive guide

(Jeff_L) #1
</build>

</project>

This will produce a MANIFEST.MF file along the following lines:


Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: johnsmart
Build-Jdk: 1.6.0_22
Jenkins-Build-Number: 63
Jenkins-Project: game-of-life
Jenkins-Version: 1.382
Implementation-Version: jenkins-game-of-life-63
Specification-Title: gameoflife-web
Specification-Version: 0.0.55-SNAPSHOT

And in a Groovy script, they can be obtained via the System.getenv() method:


def env = System.getenv()
env.each {
println it
}

or:


def env = System.getenv()
println env['BUILD_NUMBER']

5.6.5. Running Groovy Scripts


Groovy is not only a popular JVM dynamic language, it is also a convenient language for low-level
scripting. The Jenkins Groovy Plugin^10 lets you run arbitrary Groovy commands, or invoke Groovy
scripts, as part of your build process.


Once you have installed the Groovy plugin in the usual way, you need to add a reference to your
Groovy installation in the system configuration page (see Figure 5.29, “Adding a Groovy installation
to Jenkins”).


Figure 5.29. Adding a Groovy installation to Jenkins


(^10) http://wiki.jenkins-ci.org//display/HUDSON/Groovy+Plugin

Free download pdf