Projet

Général

Profil

0004-add-test-nspawn-and-Jenkinsfile-21758.patch

Christophe Siraut, 25 novembre 2019 18:26

Télécharger (2,12 ko)

Voir les différences:

Subject: [PATCH 4/5] add test-nspawn and Jenkinsfile (#21758)

 Jenkinsfile | 23 +++++++++++++++++++++++
 test-nspawn | 25 +++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 Jenkinsfile
 create mode 100755 test-nspawn
Jenkinsfile
1
@Library('eo-jenkins-lib@master') import eo.Utils
2

  
3
pipeline {
4
    agent any
5
    stages {
6
        stage('Unit Tests') {
7
            steps {
8
                sh 'sudo ./test-nspawn buster'
9
            }
10
        }
11
    }
12
    post {
13
        always {
14
            script {
15
                utils = new Utils()
16
                utils.mail_notify(currentBuild, env, 'ci+jenkins-publik-devinst@entrouvert.org')
17
            }
18
        }
19
        success {
20
            cleanWs()
21
        }
22
    }
23
}
test-nspawn
1
#!/bin/sh
2
set -ex
3

  
4
if [ $1 = 'buster' ]
5
then
6
    suite=$1
7
    image=publik-devinst-$suite
8
    fs=/var/lib/machines/$image
9
    test -d $fs || (cd /var/lib/machines && debootstrap --include=systemd-container $suite $image http://deb.debian.org/debian/)
10
    rsync -a --delete . $fs/opt/publik-devinst
11
    sudo systemd-nspawn -x -D $fs /opt/publik-devinst/test-nspawn run-tests
12
elif [ $1 = 'run-tests' ]
13
then
14
    apt update
15
    apt install -y wget ca-certificates gnupg2 git ansible postgresql sudo python
16
    adduser --disabled-password --gecos "" testuser
17
    usermod -a -G sudo testuser
18
    echo 'testuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
19
    chown -R testuser /opt/publik-devinst
20
    /usr/bin/wget https://deb.entrouvert.org/entrouvert.gpg
21
    apt-key add entrouvert.gpg
22
    apt update
23
    /etc/init.d/postgresql start
24
    su testuser -l -c 'cd /opt/publik-devinst; ansible-playbook -i inventory.yml -e "{postgresql_port: 5433}" install.yml'
25
fi
0
-