blob: 10041fe1587190297580ef58ecf0d31a09ea2faf [file] [log] [blame]
tiernod125caf2018-11-22 16:05:54 +00001/*
2 Licensed under the Apache License, Version 2.0 (the "License");
3 you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11 implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14*/
Mike Marchetti80d61ec2018-04-18 13:54:10 -040015properties([
16 parameters([
17 string(defaultValue: env.BRANCH_NAME, description: '', name: 'GERRIT_BRANCH'),
18 string(defaultValue: 'osm/NBI', description: '', name: 'GERRIT_PROJECT'),
19 string(defaultValue: env.GERRIT_REFSPEC, description: '', name: 'GERRIT_REFSPEC'),
20 string(defaultValue: env.GERRIT_PATCHSET_REVISION, description: '', name: 'GERRIT_PATCHSET_REVISION'),
21 string(defaultValue: 'https://osm.etsi.org/gerrit', description: '', name: 'PROJECT_URL_PREFIX'),
22 booleanParam(defaultValue: false, description: '', name: 'TEST_INSTALL'),
23 string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'),
24 ])
25])
26
27def devops_checkout() {
28 dir('devops') {
29 git url: "${PROJECT_URL_PREFIX}/osm/devops", branch: params.GERRIT_BRANCH
30 }
31}
32
33node('docker') {
garciadeblas30b97562020-09-11 09:13:47 +000034 stage('CURRENT PIPELINE') {
35 checkout scm
36 devops_checkout()
Mike Marchetti80d61ec2018-04-18 13:54:10 -040037
garciadeblas30b97562020-09-11 09:13:47 +000038 ci_stage_2 = load "devops/jenkins/ci-pipelines/ci_stage_2.groovy"
39 ci_stage_2.ci_pipeline('NBI',
40 params.PROJECT_URL_PREFIX,
41 params.GERRIT_PROJECT,
42 params.GERRIT_BRANCH,
43 params.GERRIT_REFSPEC,
44 params.GERRIT_PATCHSET_REVISION,
45 // params.TEST_INSTALL,
garciadeblas6c7d9552020-09-11 12:43:15 +000046 false,
garciadeblas30b97562020-09-11 09:13:47 +000047 params.ARTIFACTORY_SERVER)
48 }
49 stage('NEW PIPELINE') {
50 try {
51 switch(GERRIT_EVENT_TYPE) {
52 case "change-merged":
53 stage_name = "merge"
54 break
55
56 case "patchset-created":
57 stage_name = "patchset"
58 break
59 }
60 }
61 catch(caughtError) {
62 println("No gerrit event found")
63 }
64
65 def downstream_params = [
66 string(name: 'GERRIT_BRANCH', value: params.GERRIT_BRANCH),
67 string(name: 'GERRIT_PROJECT', value: params.GERRIT_PROJECT),
68 string(name: 'GERRIT_REFSPEC', value: params.GERRIT_REFSPEC),
69 string(name: 'GERRIT_PATCHSET_REVISION', value: params.GERRIT_PATCHSET_REVISION),
70 string(name: 'PROJECT_URL_PREFIX', value: params.PROJECT_URL_PREFIX),
71 booleanParam(name: 'TEST_INSTALL', value: params.TEST_INSTALL),
72 // next params will have to be updated with the proper values
73 string(name: 'IMAGENAME', value: 'opensourcemano/nbi'),
garciadeblasbcadd322020-09-11 12:48:25 +000074 string(name: 'DOCKER_REGISTRY', value: 'localhost:5000'),
garciadeblas30b97562020-09-11 09:13:47 +000075 string(name: 'DOCKER_REGISTRY_PROTOCOL', value: 'http://'),
76 string(name: 'DOCKER_CREDENTIALS', value: '')
77 ]
78
79 downstream_job_name = "NBI-${stage_name}"
80 echo "Triggering NEW PIPELINE"
81 build job: "${downstream_job_name}", parameters: downstream_params
82 // build job: "${downstream_job_name}", parameters: downstream_params, propagate: true
83 // It calls the new pipeline defined in Jenkinsfile.new
84 //
85 //build job: '<Job name>', parameters: [[$class: 'StringParameterValue', name: 'param1', value: 'test_param']]
86 }
Mike Marchetti80d61ec2018-04-18 13:54:10 -040087}
garciadeblas30b97562020-09-11 09:13:47 +000088