jenkins-job-dsl-plugin-example
Example of Jenkins Job DSL Plugin.
The purpose of this repo is to provide examples of job DSL. These exaple job definitions are available in dsl/
directory. You can read each of them and follow instructions which are provided in comments.
Setup
-
Run
./runJenkins.sh
-
I've failed to setup
./runJenkins.sh
to havecredentials
plugin in version1.24
installed so you have to perform this udpate manually. Open http://localhost:8080/pluginManager/, selectCredentials Plugin
and click on update button. Wait for "Download successfully" status. Then kill Jenkins i n your console and run./runJenkins.sh
again. -
Open http://localhost:8080/pluginManager/advanced in your browser and click button
Check now
(on bottom right corner) to fix NodeJS installation versions list. It is related to this issue with NodeJS plugin -
Open http://localhost:8080/configure in your browser
-
Setup JDK installations:
-
Oracle Java SE Development Kit 7u80 installation named
jdk-1.7
-
Oracle Java SE Development Kit 8u72 installation named
jdk-1.8
-
-
Setup Maven installations:
-
Apache Maven 2.2.1 installation named
maven-2
-
Apache Maven 3.3.9 installation named
maven-3
-
-
Setup NodeJS installations:
-
NodeJS 0.10.41 installation named
node-0.10
-
NodeJS 0.12.9 installation named
node-0.12
-
-
Open http://localhost:8080/credentials/ in your browser and create "username with password" global credentials for this GitHub repository and name them
github-credentials
(ID
property visible after unfolding "Advanced" options) -
Create job of type "Freestyle project" named
create-jobs
(or any other name you prefer) and configure it:-
provide this repo checkout directory as Git repository, eg.
file:///Users/yourUserName/workspace/jenkins-job-dsl-plugin-example/
-
add "Process Job DSLs" build step with
dsl/*.groovy
as "DSL Scripts" for "Look on Filesystem" option -
set "Action for removed jobs" to
Disable
-
set "Action for removed views" to
Delete
-
-
Run
create-jobs
job and check that there were no errors and couple of jobs were created
IntelliJ IDEA
JetBrains IntelliJ IDEA will prompt you to provide Groovy SDK when editing *.groovy
files. If you want quick and
painless Groovy installation then I suggest:
-
Install sdkman as decsribed on http://sdkman.io/install.html
-
Install Groovy with sdkman:
sdk install groovy
-
Provide
$HOME/.sdkman/candidates/groovy/current
as Groovy SDK location when prompted in IntelliJ IDEA
Further info about Job DSL Plugin
Official:
-
[DSL Playground[( http://job-dsl.herokuapp.com/ )
Unofficial:
Topics not covered in examples in this repo
-
Tracking of created jobs by seed job (eg. when you rename job in your DSL)
-
Job with "publish over SSH" step
-
Job which needs virtual frame buffer (xvfb) to run tests (eg. Portractor tests)
-
Jobs generated for branches fetched from GitHub API. Generally: REST API calls
-
Job with multi-line shell script
-
Job for multi-phase project (with "subjobs")
-
Job with critical blocks
-
Job with remote shell access
-
Job with parameters to choose on start
-
Job with custom XML parts (if something is not provided with Job DSL Plugin)ĶĶ
-
DSLs for views
-
Testing DSLs
-
seed job updated (and extended) from DSL (inception! ;-) )