Merge lp:~canonical-platform-qa/qa-jenkins-jobs/deployment-job into lp:qa-jenkins-jobs

Proposed by Max Brustkern
Status: Merged
Approved by: Allan LeSage
Approved revision: 61
Merged at revision: 48
Proposed branch: lp:~canonical-platform-qa/qa-jenkins-jobs/deployment-job
Merge into: lp:qa-jenkins-jobs
Diff against target: 235 lines (+176/-2)
8 files modified
Makefile (+2/-0)
README (+51/-0)
debian/control (+2/-2)
debian/tests/control (+3/-0)
debian/tests/test-deploy (+2/-0)
jobs.yaml (+51/-0)
jobs/jobs.yaml (+52/-0)
scripts/deploy-jobs.sh (+13/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/qa-jenkins-jobs/deployment-job
Reviewer Review Type Date Requested Status
Allan LeSage (community) Approve
Review via email: mp+295265@code.launchpad.net

Description of the change

This branch adds:
- A script to deploy jobs from trunk (this will be expanded in the future)
- A job to automatically branch trunk and run that script
- Job configurations to the package
- A dep8 test that verifies the deployment script can run a test deployment of the job configurations

Once this is landed and deployed, we'll have auto-deployment of anything landed in qa-jenkins-jobs. Since we'll also have a test, my next update will be autolanding of qa-jenkins-jobs. From there, we can work on making the job configurations automatically generated (i.e., the auto-upgrade-testing jobs will be populated based on the auto-upgrade-testing-specifications branch instead of a list that has to be updated separately.

To post a comment you must log in.
60. By Max Brustkern

Install pip before running it

61. By Max Brustkern

Added README

Revision history for this message
Allan LeSage (allanlesage) wrote :

Ok thanks I think this is clearer!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2016-03-08 19:52:05 +0000
3+++ Makefile 2016-06-02 19:06:01 +0000
4@@ -6,3 +6,5 @@
5 NEWNAME=$$(basename "$$FILE" | sed 's/\.sh//'); \
6 cp "$$FILE" "$$DESTDIR/usr/bin/$$NEWNAME"; \
7 done
8+ mkdir -p "$$DESTDIR/usr/share"
9+ cp -r jobs "$$DESTDIR/usr/share/qa-jenkins-jobs"
10
11=== added file 'README'
12--- README 1970-01-01 00:00:00 +0000
13+++ README 2016-06-02 19:06:01 +0000
14@@ -0,0 +1,51 @@
15+qa-jenkins-jobs
16+
17+This package provides automated testing jobs for deployment using
18+jenkins-job-builder. It is primarily intended for deployed on the Canonical QA
19+Team jenkins-as-a-service instance at https://platform-qa-jenkins.ubuntu.com
20+
21+- jobs:
22+ This directory contains yaml files that work with jenkins-job-builder.
23+ At present, they require no preparation to de deployed from source, but this
24+ is likely to change in the future. As such, deploying them directly is not
25+ recommended.
26+
27+- scripts:
28+ This directory contains scripts used by the jobs as well as the deployment
29+ script.
30+ - deploy-jobs.sh:
31+ This script is maintained as the supported way to install the jobs. It
32+ Requires the jenkins_jobs module to be installed for python2. Python3
33+ support is planned once unicode issues are resolved.
34+ Run without arguments, it will attempt to recursively install jobs from a
35+ "jobs" directory in the parent directory if the script's location (i.e., if
36+ the script is in /path/to/scripts/deploy-jobs.sh, it will use /path/to/jobs
37+ as the jobs directory.) It can accept a JOB_PATH environment variable to
38+ use an arbitrary directory. If the "test" environment is passed, it will
39+ use the test argument instead of the update argument. For actual
40+ deployment, it expects a config file in the default j-j-b location
41+ (/etc/jenkins_jobs/jenkins_jobs.ini) in the format:
42+
43+[jenkins]
44+user=myuser
45+password=mypassword
46+url=http://myjenkins.url
47+
48+- Makefile:
49+ The makefile currently only contains an install target. This will install all
50+ scripts ending with .sh under the scripts directory in /usr/bin without the
51+ .sh extension. It will install the jobs directory at
52+ /usr/share/qa-jenkins-jobs
53+
54+- debian:
55+ This contains debian packaging files, including one dep8 test. The dep8 test
56+ runs deploy-jobs test with JOB_PATH set to /usr/share/qa-jenkins-jobs
57+ This should verify that the jobs are installed correctly and can be processed
58+ into valid XML buy the jenkins_jobs module. It is relatively safe to run on
59+ arbitrary targets (only package files are installed, and no remote servers
60+ are accessed.)
61+
62+- Basic testing:
63+ Run:
64+ scripts/deploy-jobs.sh test
65+ XML should print to stdout, and the exit status should be 0
66
67=== modified file 'debian/control'
68--- debian/control 2016-03-08 19:52:05 +0000
69+++ debian/control 2016-06-02 19:06:01 +0000
70@@ -3,8 +3,8 @@
71 Priority: optional
72 Maintainer: Max Brustkern <max@canonical.com>
73 Build-Depends: debhelper (>= 9)
74-Standards-Version: 3.9.6
75-Homepage: https://launchpade.net/qa-jenkins-jobs
76+Standards-Version: 3.9.7
77+Homepage: https://launchpad.net/qa-jenkins-jobs
78
79 Package: qa-jenkins-jobs
80 Architecture: any
81
82=== added directory 'debian/tests'
83=== added file 'debian/tests/control'
84--- debian/tests/control 1970-01-01 00:00:00 +0000
85+++ debian/tests/control 2016-06-02 19:06:01 +0000
86@@ -0,0 +1,3 @@
87+Tests: test-deploy
88+Restrictions: allow-stderr
89+Depends: python-jenkins-job-builder, qa-jenkins-jobs
90
91=== added file 'debian/tests/test-deploy'
92--- debian/tests/test-deploy 1970-01-01 00:00:00 +0000
93+++ debian/tests/test-deploy 2016-06-02 19:06:01 +0000
94@@ -0,0 +1,2 @@
95+export JOB_PATH=/usr/share/qa-jenkins-jobs
96+deploy-jobs test
97
98=== added directory 'jobs'
99=== added file 'jobs.yaml'
100--- jobs.yaml 1970-01-01 00:00:00 +0000
101+++ jobs.yaml 2016-06-02 19:06:01 +0000
102@@ -0,0 +1,51 @@
103+# vim: sw=4 ts=4 et
104+
105+# QA Jenkins Jobs
106+# Copyright 2016 Canonical Ltd.
107+
108+# This program is free software: you can redistribute it and/or modify it
109+# under the terms of the GNU General Public License version 3, as published
110+# by the Free Software Foundation.
111+
112+# This program is distributed in the hope that it will be useful, but
113+# WITHOUT ANY WARRANTY; without even the implied warranties of
114+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
115+# PURPOSE. See the GNU General Public License for more details.
116+
117+# You should have received a copy of the GNU General Public License along
118+# with this program. If not, see <http://www.gnu.org/licenses/>.
119+
120+# The project stanza describes all jobs and parameters
121+- project:
122+ name: qa-jenkins-jobs
123+ node: 'iso-testing'
124+ jobs:
125+ - 'setup-qa-jobs'
126+ - 'deploy-qa-jobs'
127+
128+- job:
129+ name: setup-qa-jobs
130+ description: |
131+ This job provides dependencies for qa jobs.
132+ It can be rerun to update them.
133+ Defined in lp:qa-jenkins-job
134+ builder:
135+ - shell: |
136+ pip install --user jenkins-job-builder
137+
138+- job:
139+ name: deploy-qa-jobs
140+ description: |
141+ This job automatically deploys qa-jenkins-job from trunk periodically.
142+ Defined in lp:qa-jenkins-jobs
143+ node: 'iso-testing'
144+ triggers:
145+ - timed: 'H/30 * * * *'
146+ builders:
147+ - clear-artifacts:
148+ - shell: |
149+ BRANCH="lp:qa-jenkins-jobs"
150+ BRANCH_DIR=qa-jenkins-jobs
151+ bzr export "$BRANCH" "$BRANCH_DIR"
152+ cd "$BRANCH_DIR"
153+ ./scripts/deploy-jobs.sh
154
155=== renamed directory 'auto-upgrade-testing' => 'jobs/auto-upgrade-testing'
156=== renamed file 'defaults.yaml' => 'jobs/defaults.yaml'
157=== renamed directory 'iso-testing' => 'jobs/iso-testing'
158=== added file 'jobs/jobs.yaml'
159--- jobs/jobs.yaml 1970-01-01 00:00:00 +0000
160+++ jobs/jobs.yaml 2016-06-02 19:06:01 +0000
161@@ -0,0 +1,52 @@
162+# vim: sw=4 ts=4 et
163+
164+# QA Jenkins Jobs
165+# Copyright 2016 Canonical Ltd.
166+
167+# This program is free software: you can redistribute it and/or modify it
168+# under the terms of the GNU General Public License version 3, as published
169+# by the Free Software Foundation.
170+
171+# This program is distributed in the hope that it will be useful, but
172+# WITHOUT ANY WARRANTY; without even the implied warranties of
173+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
174+# PURPOSE. See the GNU General Public License for more details.
175+
176+# You should have received a copy of the GNU General Public License along
177+# with this program. If not, see <http://www.gnu.org/licenses/>.
178+
179+# The project stanza describes all jobs and parameters
180+- project:
181+ name: qa-jenkins-jobs
182+ node: 'iso-testing'
183+ jobs:
184+ - 'setup-qa-jobs'
185+ - 'deploy-qa-jobs'
186+
187+- job:
188+ name: setup-qa-jobs
189+ description: |
190+ This job provides dependencies for qa jobs.
191+ It can be rerun to update them.
192+ Defined in lp:qa-jenkins-job
193+ builder:
194+ - shell: |
195+ sudo apt-get install python-pip
196+ pip install --user jenkins-job-builder
197+
198+- job:
199+ name: deploy-qa-jobs
200+ description: |
201+ This job automatically deploys qa-jenkins-job from trunk periodically.
202+ Defined in lp:qa-jenkins-jobs
203+ node: 'iso-testing'
204+ triggers:
205+ - timed: '*/30 * * * *'
206+ builders:
207+ - clear-artifacts:
208+ - shell: |
209+ BRANCH="lp:qa-jenkins-jobs"
210+ BRANCH_DIR=qa-jenkins-jobs
211+ bzr export "$BRANCH_DIR" "$BRANCH"
212+ cd "$BRANCH_DIR"
213+ ./scripts/deploy-jobs.sh
214
215=== renamed file 'macros.yaml' => 'jobs/macros.yaml'
216=== renamed directory 'mp-ci-autoland' => 'jobs/mp-ci-autoland'
217=== renamed directory 'ubiquity' => 'jobs/ubiquity'
218=== renamed directory 'ubuntu-system-tests' => 'jobs/ubuntu-system-tests'
219=== added file 'scripts/deploy-jobs.sh'
220--- scripts/deploy-jobs.sh 1970-01-01 00:00:00 +0000
221+++ scripts/deploy-jobs.sh 2016-06-02 19:06:01 +0000
222@@ -0,0 +1,13 @@
223+#!/bin/sh
224+
225+set -ex
226+
227+JOB_PATH=${JOB_PATH-"$(cd "$(dirname "$0")"; pwd)"/../jobs}
228+case $1 in
229+ test)
230+ ARGS="test";;
231+ *)
232+ ARGS="update";;
233+esac
234+
235+python -m jenkins_jobs.cmd $ARGS -r "$JOB_PATH"

Subscribers

People subscribed via source and target branches