Skip to content

Declarative Jenkins job configuration. Update Jenkins from a Git repository.

License

Notifications You must be signed in to change notification settings

timaa2k/jenkinscfg

Repository files navigation

jenkinscfg

Update Jenkins jobs configuration declaratively from a Git repository.

Installation

$ pip install jenkinscfg

Usage

Usage: jenkinscfg [OPTIONS] COMMAND [ARGS]...

Options:
  -h, --host TEXT
  -u, --username TEXT
  -p, --password TEXT
  --version            Show the version and exit.
  --help               Show this message and exit.

Commands:
  diff
  dump
  update

Example

$ export JENKINS_HOST=http://old.leeroy.jenkins:8080
$ jenkinscfg dump jobs
$ tree jobs
jobs
└── HelloWorldJobFolder
   ├── config.xml
   └── HelloWorldJob
      └── config.xml
$ export JENKINS_HOST=http://new.better.jenkins:8080
$ jenkinscfg update jobs
Creating HelloWorldJobFolder
Creating HelloWorldJobFolder/HelloWorldJob
$ mv jobs/HelloWorldJobFolder jobs/NewJobFolder
$ jenkinscfg diff jobs
Removed   HelloWorldJobFolder
Removed   HelloWorldJobFolder/HelloWorldJob
Added     NewJobFolder
Added     NewJobFolder/HelloWorldJob
$ jenkinscfg update jobs
Deleting HelloWorldJobFolder/HelloWorldJob
Deleting HelloWorldJobFolder
Creating NewJobFolder
Creating NewJobFolder/HelloWorldJob
$ sed -i 's/false/true/' jobs/NewJobFolder/HelloWorldJob/config.xml
$ jenkinscfg diff jobs
Changed   NewJobFolder/HelloWorldJob
---
+++
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?><project>
-  <keepDependencies>false</keepDependencies>
+  <keepDependencies>true</keepDependencies>
   <properties/>
   <scm class="jenkins.scm.NullSCM"/>
   <canRoam>true</canRoam>
-  <disabled>false</disabled>
-  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+  <disabled>true</disabled>
+  <blockBuildWhenUpstreamBuilding>true</blockBuildWhenUpstreamBuilding>
   <triggers class="vector"/>
-  <concurrentBuild>false</concurrentBuild>
+  <concurrentBuild>true</concurrentBuild>
   <builders/>
   <publishers/>
   <buildWrappers/>

Unchanged NewJobFolder
$ jenkinscfg update jobs
Updating NewJobFolder/HelloWorldJob