1
jenkins-launchpad-plugin is a set of scripts for polling launchpad (looking
2
for new merge proposals) and for updating launchpad merge proposals with
3
different messages and votes.
8
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin
14
* ``bin/launchpadTrigger`` - This is the main polling scripts. It looks for
15
a specific merge proposals (e.g. "Needs review" or "Approved") of a given
16
target branch (e.g. lp:unity) and starts a given jenkins job. The
17
responsibilities of this script end with starting the job.
18
* ``bin/voteOnMergeProposal`` - This script adds a vote to a given merge
19
proposal together with links to all relevant jenkins jobs that were
20
executed. This is usually used for merge proposals which are in "Needs
21
review" and no further action is needed (such as merging the code)
22
* ``bin/autoland`` - Takes care of the actual merge and possibly dputs to
23
(one or many) PPA. This script is usually used for merge proposals in
25
* ``bin/dput`` - Helper script for dputing into PPA.
28
How it works with jenkins
29
=========================
31
Step 1 - Jenkins job doing the actual testing
32
---------------------------------------------
33
The first step is to create a jenkins job where you want to do your
34
testing. Multiconfiguration (aka Matrix) jobs are supported as well as
35
unlimited depth of downstream jobs. Results from all are posted to the
36
merge proposal (with some filtering possible).
38
In order to use the launchpadTrigger script the job needs to accept the
39
following string parameters which are both automatically set by
40
launchpadTrigger at the time of triggering:
41
* merge_proposal - URL of the merge proposal
42
* candidate_revision - revision of the branch that is being tested
43
(this is to make sure we are consistent in what we test)
45
This is how it looks in jenkins:
47
.. image:: images/job_params.png
49
We usually have two jobs per project. One called $project-ci (triggered
50
whenever a new merge proposal is created) and one called $project-autoland
51
which is triggered when a merge proposal is Approved. They primarily differ
52
in the post build action. While the jenkins bot only votes (Needs
53
Fixing/Approved) for merge proposals in 'Needs review' it votes _and_
54
merges the code for proposals in 'Approved'.
56
Step 2 - Triggering the jenkins job
57
-----------------------------------
58
Once we have a jenkins job we need to trigger it. There are at least two
61
jenkins ScriptTrigger plugin
62
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64
In the triggering section you can run something like::
66
launchpadTrigger --job=$YOUR_JOB --branch=lp:$YOUR_PROJECT --trigger-ci
68
This is how it looks in jenkins:
70
.. image:: images/scripttrigger.png
72
With the script above your job will be started whenever there is a
73
new merge proposal in 'Needs review' state.
74
If you want to start the testing for 'Approved' merge proposals you
75
can use ``--autoland`` instead of ``--trigger-ci``.
77
Using the ScriptTrigger plugin is however not recommended as there
78
are scalability issues. Once you have a lot of projects it is hard to
79
debug issues and it behaves weirdly. It is, however, not an issue for
80
a small amount of projects (lets say ~10).
83
custom jenkins (cron) job
84
^^^^^^^^^^^^^^^^^^^^^^^^^
85
We are currently using a custom job called trigger-ci-and-autolanding. This
86
job is triggered by timer (every 15 minutes), reads the configuration from
87
lp:cupstream2distro-config (this config essentially defines the YOUR_JOB <->
88
YOUR_PROJECT pairing) and polls all the jobs from the config.
91
Step 3 - job is finished, what now?
92
-----------------------------------
93
After your testing job is finished we want to update the merge proposal or
94
merge the code (or whatever you want). For that purpose we are using couple
95
of custom jobs which are executed from a post-build section of your jenkins
100
This job executes the voteOnMergeProposal script and you need the pass some
101
info from $YOUR_JOB to this via parameters (see the screenshot below). You
102
need to trigger generic-update_mp with different parameters depending on
103
the result of your job. Fortunately the jenkins "Parameterized Trigger Plugin" can help here.
105
.. image:: images/generic-update_mp_trigger.png
107
Build section of generic-update_mp might look like this:
109
.. image:: images/generic-update_mp_build.png
114
This job is executed when you want to merge the code rather than just to vote.
115
There are again few options how to configure it.
117
In case $YOUR_JOB is a multiconfiguration job then the landing can't happen
118
in the build step as you would be trying to merge several times (one time
119
per configuration). You need to use post-build section in a way similar to
122
.. image:: images/generic-update_mp_trigger.png
124
As the ``autoland`` script takes more arguments the ``voteOnMergeProposal``
125
you might want to pass more variables here. See ``autoland --help`` for
126
more information on supported options.
133
The following example is a real vote on a merge proposal for
136
There is a following job structure:
138
* ``unity-phablet-ci`` - the "master" ci job triggered whenever a new jenkins merge proposal is created. This job triggers the following jobs:
140
* ``unity-phablet-qmluitests`` - this job is not configured to be published
141
on jenkins.qa.ubuntu.com and therefore the internal IP is mangled to
142
s-jenkins (see ``settings.py``)
143
* ``unity-phablet-[quantal|raring]-[armhf|i386]-ci`` - jobs building on
144
quantal and raring and armhf and i386. The armhf jobs are configured to
145
archive the resulting deb files for future use and therefore a link to
146
that deb is printed too.
147
* ``generic-mediumtests-runner`` - job that is running autopilot (UI tests)
149
In total there are 6 different jenkins jobs with tests + 1 master which
150
controls them all and then executes the ``generic-update_mp`` job.
152
The downstream jobs might be whatever you like. For some projects we have
155
Even though ``generic-update_mp`` is downstream to unity-phablet-ci it is
156
filtered from the message (see ``settings.py``) as well as few other
159
.. image:: images/mp_example.png