Commit | Line | Data |
---|---|---|
0b51cf96 | 1 | #!/bin/bash -ex |
9c41f7e2 JR |
2 | # |
3 | # Copyright (C) 2016 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation, either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | PYTHON_2_ENV=$WORKSPACE"/.python2_venv" | |
19 | PYTHON_3_ENV=$WORKSPACE"/.python3_venv" | |
20 | ||
0b51cf96 JR |
21 | # Prepare JJB python 2 environment |
22 | set -x | |
23 | if [ ! -d "$PYTHON_2_ENV" ]; then | |
24 | virtualenv -p python2 $PYTHON_2_ENV | |
25 | fi | |
26 | set +x | |
9c41f7e2 | 27 | |
0b51cf96 JR |
28 | . $PYTHON_2_ENV/bin/activate |
29 | pip install --force-reinstall git+git://github.com/mjeanson/jenkins-job-builder@ci | |
30 | deactivate | |
9c41f7e2 | 31 | |
0b51cf96 JR |
32 | # Prepare python 3 env |
33 | if [ ! -d "$PYTHON_3_ENV" ]; then | |
34 | virtualenv -p python3 $PYTHON_3_ENV | |
35 | fi | |
9c41f7e2 | 36 | |
0b51cf96 JR |
37 | . $PYTHON_3_ENV/bin/activate |
38 | pip install --upgrade gitpython pyyaml | |
9c41f7e2 JR |
39 | deactivate |
40 | ||
0b51cf96 | 41 | # Prepare the configuration file for jjb |
9c41f7e2 JR |
42 | cp $WORKSPACE/etc/jenkins_jobs.ini-sample $WORKSPACE/etc/jenkins_jobs.ini |
43 | ||
0b51cf96 JR |
44 | # Set +x: hide information from the jenkins console log since we use injected |
45 | # secrets | |
9c41f7e2 JR |
46 | set +x |
47 | sed -i -e "s/user=jenkins/user=$JJB_JENKINS_USER/g" $WORKSPACE/etc/jenkins_jobs.ini | |
48 | sed -i -e "s/password=1234567890abcdef1234567890abcdef/password=$JJB_JENKINS_TOKEN/g" $WORKSPACE/etc/jenkins_jobs.ini | |
49 | set -x | |
50 | ||
0b51cf96 JR |
51 | #Prepare the kernel |
52 | if [ ! -d "$WORKSPACE/kernel" ]; then | |
53 | git clone git://artifacts.internal.efficios.com/git/linux-stable.git $WORKSPACE/kernel | |
54 | else | |
55 | pushd $WORKSPACE/kernel | |
56 | git fetch --tags origin | |
57 | popd | |
58 | fi | |
59 | ||
60 | # Clean the previous rc | |
61 | # Note: this step is stateful since it use the last generated version. | |
62 | . $PYTHON_2_ENV/bin/activate | |
9c41f7e2 | 63 | jenkins-jobs --conf $WORKSPACE/etc/jenkins_jobs.ini delete --path $WORKSPACE/jobs/lttng-modules.yaml:$WORKSPACE/jobs/kernel.yaml \*rc\*_build |
0b51cf96 | 64 | deactivate |
9c41f7e2 | 65 | |
0b51cf96 JR |
66 | # Run the kernel seed generator |
67 | . $PYTHON_3_ENV/bin/activate | |
68 | python $WORKSPACE/automation/kernel-seed.py --kernel-path $WORKSPACE/kernel --kernel-cutoff 2.6.36 > $WORKSPACE/jobs/inc/kernel-versions.yaml.inc | |
69 | deactivate | |
70 | ||
71 | . $PYTHON_2_ENV/bin/activate | |
72 | jenkins-jobs --conf $WORKSPACE/etc/jenkins_jobs.ini update $WORKSPACE/jobs/lttng-modules.yaml:$WORKSPACE/jobs/kernel.yaml | |
9c41f7e2 | 73 | deactivate |
0b51cf96 JR |
74 | |
75 | # Flush the configuration file so no one can access it | |
76 | rm -f $WORKSPACE/etc/jenkins_jobs.ini | |
9c41f7e2 | 77 | # EOF |