Jenkins Startup Scripts Runner

May 17, 2018 ยท View on GitHub

Build Status Download

A framework to enable configuration of jenkins at startup.

Using the Runner

The simplest way to use the runner is via the Buildit Jenkins Image.

To use the runner outside of the image, unzip the build artifact to $JENKINS_HOME/init.groovy.d and provide the configuration as described in the README.md of the Jenkins Config Fetcher.

Startup Scripts

An archive of startup scripts can be pulled from a remote location at runtime. The following configuration block in a .config file will initiate a download of jenkins-startup-scripts-X-X-X.zip from bintray during startup.

startupScripts=[
        bintray: [
                artifactPattern: 'https://dl.bintray.com/buildit/maven/com/buildit/[module]/[revision]/[module]-[revision].[ext]',
                artifacts: [":jenkins-startup-scripts:X.X.X@zip"]
        ]
]

The runner will then proceed to unzip the archive, add any jars in the lib directory to the classpath and look for a file called main.groovy in the archive's root directory before binding the jenkinsConfig value (with the entire parsed config) and running the main.main() method.

The original set of startup scripts can be found here - Jenkins Startup Scripts. It is possible to provide other scripts by just following the pattern above.

Running the Runner

The runner is designed to trigger as a Jenkins Hook Script - meaning it will run whenever Jenkins is restarted.

It is also possible to trigger the runner manually by running

new GroovyShell(this.class.classLoader).evaluate(new File("${System.getenv('JENKINS_HOME')}/init.groovy.d/runner.groovy"))

from the jenkins script console.