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 Get_MDG(project) {
20 def values = project.split('/')
21 if ( values.size() > 1 ) {
24 // no prefix, likely just the project name then
28 node("${params.NODE}") {
30 mdg = Get_MDG("${GERRIT_PROJECT}")
31 println("MDG is ${mdg}")
33 if ( params.PROJECT_URL_PREFIX == null )
35 params.PROJECT_URL_PREFIX = 'https://osm.etsi.org/gerrit'
39 // initially use stage_name as the event_type
40 def stage_name = GERRIT_EVENT_TYPE
42 switch(GERRIT_EVENT_TYPE) {
44 stage_name = "stage_2-merge"
47 case "patchset-created":
48 stage_name = "stage_2"
52 if (params.DO_STAGE_4)
54 do_stage_4 = params.DO_STAGE_4
57 // pipeline running from gerrit trigger.
58 // kickoff the downstream multibranch pipeline
59 def downstream_params = [
60 string(name: 'GERRIT_BRANCH', value: GERRIT_BRANCH),
61 string(name: 'GERRIT_PROJECT', value: GERRIT_PROJECT),
62 string(name: 'GERRIT_REFSPEC', value: GERRIT_REFSPEC),
63 string(name: 'GERRIT_PATCHSET_REVISION', value: GERRIT_PATCHSET_REVISION),
64 string(name: 'PROJECT_URL_PREFIX', value: params.PROJECT_URL_PREFIX),
65 booleanParam(name: 'TEST_INSTALL', value: params.TEST_INSTALL),
66 booleanParam(name: 'DO_STAGE_4', value: do_stage_4),
71 // go directly to stage 3 (osm system)
72 stage_name = "stage_3"
74 if ( ! params.TEST_INSTALL )
76 println("disabling stage_3 invocation")
80 // callout to stage_2. This is a multi-branch pipeline.
81 downstream_job_name = "${mdg}-${stage_name}/${GERRIT_BRANCH}"
83 println("TEST_INSTALL = ${params.TEST_INSTALL}, downstream job: ${downstream_job_name}")
85 stage_2_result = build job: "${downstream_job_name}", parameters: downstream_params, propagate: true
86 if (stage_2_result.getResult() != 'SUCCESS') {
87 project = stage_2_result.getProjectName()
88 build = stage_2_result.getNumber()
89 error("${project} build ${build} failed")