Run generator_kernel on master and keep the version state
[lttng-ci.git] / scripts / kernel / job-generator-kernel.sh
CommitLineData
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
18PYTHON_2_ENV=$WORKSPACE"/.python2_venv"
19PYTHON_3_ENV=$WORKSPACE"/.python3_venv"
20
0b51cf96
JR
21# Prepare JJB python 2 environment
22set -x
23if [ ! -d "$PYTHON_2_ENV" ]; then
24 virtualenv -p python2 $PYTHON_2_ENV
25fi
26set +x
9c41f7e2 27
0b51cf96
JR
28. $PYTHON_2_ENV/bin/activate
29pip install --force-reinstall git+git://github.com/mjeanson/jenkins-job-builder@ci
30deactivate
9c41f7e2 31
0b51cf96
JR
32# Prepare python 3 env
33if [ ! -d "$PYTHON_3_ENV" ]; then
34 virtualenv -p python3 $PYTHON_3_ENV
35fi
9c41f7e2 36
0b51cf96
JR
37. $PYTHON_3_ENV/bin/activate
38pip install --upgrade gitpython pyyaml
9c41f7e2
JR
39deactivate
40
0b51cf96 41# Prepare the configuration file for jjb
9c41f7e2
JR
42cp $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
46set +x
47sed -i -e "s/user=jenkins/user=$JJB_JENKINS_USER/g" $WORKSPACE/etc/jenkins_jobs.ini
48sed -i -e "s/password=1234567890abcdef1234567890abcdef/password=$JJB_JENKINS_TOKEN/g" $WORKSPACE/etc/jenkins_jobs.ini
49set -x
50
0b51cf96
JR
51#Prepare the kernel
52if [ ! -d "$WORKSPACE/kernel" ]; then
53 git clone git://artifacts.internal.efficios.com/git/linux-stable.git $WORKSPACE/kernel
54else
55 pushd $WORKSPACE/kernel
56 git fetch --tags origin
57 popd
58fi
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 63jenkins-jobs --conf $WORKSPACE/etc/jenkins_jobs.ini delete --path $WORKSPACE/jobs/lttng-modules.yaml:$WORKSPACE/jobs/kernel.yaml \*rc\*_build
0b51cf96 64deactivate
9c41f7e2 65
0b51cf96
JR
66# Run the kernel seed generator
67. $PYTHON_3_ENV/bin/activate
68python $WORKSPACE/automation/kernel-seed.py --kernel-path $WORKSPACE/kernel --kernel-cutoff 2.6.36 > $WORKSPACE/jobs/inc/kernel-versions.yaml.inc
69deactivate
70
71. $PYTHON_2_ENV/bin/activate
72jenkins-jobs --conf $WORKSPACE/etc/jenkins_jobs.ini update $WORKSPACE/jobs/lttng-modules.yaml:$WORKSPACE/jobs/kernel.yaml
9c41f7e2 73deactivate
0b51cf96
JR
74
75# Flush the configuration file so no one can access it
76rm -f $WORKSPACE/etc/jenkins_jobs.ini
9c41f7e2 77# EOF
This page took 0.025576 seconds and 4 git commands to generate.