1 /* Copyright 2017 Sandvine
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
18 def project_checkout(url_prefix,project,refspec,revision) {
19 // checkout the project
20 // this is done automaticaly by the multibranch pipeline plugin
21 // git url: "${url_prefix}/${project}"
23 sh "git fetch origin ${refspec}"
24 if (GERRIT_PATCHSET_REVISION.size() > 0 ) {
25 sh "git checkout -f ${revision}"
29 def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,build_system) {
30 println("build_system = ${build_system}")
31 ci_helper = load "devops/jenkins/ci-pipelines/ci_helper.groovy"
38 project_checkout(url_prefix,project,refspec,revision)
41 container_name = "${project}-${branch}".toLowerCase()
43 stage('Docker-Build') {
44 sh "docker build -t ${container_name} ."
47 withDockerContainer("${container_name}") {
48 stage('Docker-Setup') {
50 groupadd -o -g $(id -g) -r jenkins
51 useradd -o -u $(id -u) --create-home -r -g jenkins jenkins
55 sh 'devops-stages/stage-test.sh'
58 sh(returnStdout:true, script: 'devops-stages/stage-build.sh').trim()
63 sh(returnStdout:true, script: 'devops-stages/stage-archive.sh').trim()
64 ci_helper.archive(mdg,branch,'untested')
69 stage('Build System') {
70 def downstream_params_stage_3 = [
71 string(name: 'GERRIT_BRANCH', value: "${branch}"),
72 string(name: 'UPSTREAM_JOB_NAME', value: "${JOB_NAME}" ),
73 string(name: 'UPSTREAM_JOB_NUMBER', value: "${BUILD_NUMBER}" ),
76 // callout to stage_3. This is the system build
77 result = build job: "osm-stage_3/${branch}", parameters: downstream_params_stage_3, propagate: true
78 if (result.getResult() != 'SUCCESS') {
79 project = result.getProjectName()
80 build = result.getNumber()
81 error("${project} build ${build} failed")