blob: e3f20e92999d03f7463d83a7a7a7cfdf320eff38 [file] [log] [blame]
Jeremy Ronquillo6072a982020-04-16 13:18:24 -07001// Copyright 2020-present Open Networking Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// comac-in-a-box-gerrit build+test
16// steps taken from https://guide.opencord.org/profiles/comac/install/ciab.html
17
18pipeline {
19
20 /* no label, executor is determined by JJB */
21 agent {
22 label "${params.buildNode}"
23 }
24
25 options {
26 timeout(time: 1, unit: 'HOURS')
27 }
28
29 stages {
30 stage ("Environment Setup"){
31 steps {
32 sh label: 'Run COMAC-in-a-box reset-test', script: """
33 echo $HOME
34 cd $HOME/automation-tools/comac-in-a-box/
35 sudo make reset-test
36 """
37 sh label: 'Cleanup Docker Images', script: '''
38 sudo docker rmi -f $(sudo docker images --format '{{.Repository}} {{.ID}}' | grep 'none' | awk '{print $2}') || true
39 sudo docker rmi -f $(sudo docker images --format '{{.Repository}}:{{.Tag}}' | grep 'openmme') || true
40 sudo docker rmi -f $(sudo docker images --format '{{.Repository}}:{{.Tag}}' | grep 'ngic') || true
41 sudo docker rmi -f $(sudo docker images --format '{{.Repository}}:{{.Tag}}' | grep 'c3po') || true
42 '''
43 sh label: 'helm-charts Repo Fresh Clone', script: """
44 cd $HOME/cord/
45 sudo rm -rf helm-charts/
46 git clone https://gerrit.opencord.org/helm-charts
47 """
48 }
49 }
50
51 stage ("Fetch Helm-Charts Changes"){
52 steps {
53 sh label: 'Fetch helm-charts Gerrit Changes', script: """
54 cd $HOME/cord/helm-charts/
55 if [ ! -z "${GERRIT_REFSPEC}" ]
56 then
57 echo "Checking out Gerrit patchset: ${GERRIT_REFSPEC}"
58 git fetch ${gitUrl} ${GERRIT_REFSPEC} && git checkout FETCH_HEAD
59 else
60 echo "GERRIT_REFSPEC not provided. Checking out master branch."
61 git checkout master
62 fi
63 """
64 }
65 }
66
67 stage ("Run COMAC-in-a-box"){
68 steps {
Jeremy Ronquilloa8701752020-04-28 15:17:01 -070069 script{
70 try{
71 sh label: 'Run Makefile', script: """
72 cd $HOME/automation-tools/comac-in-a-box/
73 sudo make reset-test
74 sudo make test
75 """
76 } finally {
77 sh label: 'Archive Logs', script: '''
78 mkdir logs
79 mkdir logs/pods
80 kubectl get pods -n omec > logs/kubectl_get_pods_omec.log
81 for pod in $(kubectl get pods -n omec | awk '{print $1}' | tail -n +2)
82 do
83 kubectl logs -n omec $pod --all-containers > logs/pods/$pod.log || true
84 done
85 '''
86 archiveArtifacts artifacts: "logs/**/*.log", allowEmptyArchive: true
87 }
88 }
Jeremy Ronquillo6072a982020-04-16 13:18:24 -070089 }
90 }
91 }
92}