systest jenkins pipeline
[osm/devops.git] / systest / Jenkinsfile
1 // input parameters:
2 //   string:  UPSTREAM_PROJECT
3 //   string:  NODE
4 //
5 //   OpenStack VIM Credentials
6 //   string:  OS_AUTH_URL
7 //   string:  OS_USERNAME
8 //   string:  OS_PASSWORD
9 //   string:  OS_PROJECT_NAME
10
11 node("${params.NODE}") {
12
13     // grab the upstream artifact name
14     step ([$class: 'CopyArtifact',
15           projectName: params.UPSTREAM_PROJECT])
16
17     container_name = sh(returnStdout: true, script: 'cat build_version.txt').trim()
18
19     stage("get osm") {
20         // get the IP of the osm container
21         OSM_IP = sh(returnStdout: true, script: "lxc list ${container_name} -c 4|grep eth0 |awk '{print \$2}'").trim()
22     }
23     stage("checkout") {
24         checkout scm
25     }
26
27     // build the pytest container
28     stage("build-docker") {
29         sh 'docker build -t osmclient systest/.'
30     }
31
32     os_credentials = "OS_AUTH_URL=${params.OS_AUTH_URL} OS_USERNAME=${params.OS_USERNAME} OS_PASSWORD=${params.OS_PASSWORD} OS_PROJECT_NAME=${params.OS_PROJECT_NAME}"
33
34     // now run the built container.
35     withDockerContainer('osmclient') {
36
37         // install the osmclient
38         stage("install-osmclient") {
39             sh 'pip install git+https://osm.etsi.org/gerrit/osm/osmclient'
40         }
41
42         stage("build-descriptors") {
43             sh "make -C systest descriptors"
44         }
45
46         stage("smoke-test") {
47             sh "make -C systest OSM_HOSTNAME=${OSM_IP} smoke"
48             junit 'systest/reports/pytest-smoke.xml'
49         }
50
51         stage("cirros-test") {
52             sh """
53                make -C systest OSM_HOSTNAME=${OSM_IP} ${os_credentials} cirros
54                """
55             junit 'systest/reports/pytest-cirros.xml'
56         }
57     }
58 }