-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
157 lines (128 loc) · 4.7 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!groovy
// Testing pipeline
pipeline {
agent {
label 'hamlet-latest'
}
options {
timestamps ()
buildDiscarder(
logRotator(
numToKeepStr: '10'
)
)
disableConcurrentBuilds()
durabilityHint('PERFORMANCE_OPTIMIZED')
parallelsAlwaysFailFast()
skipDefaultCheckout()
quietPeriod 60
}
environment {
DOCKER_BUILD_DIR = "${env.DOCKER_STAGE_DIR}/${BUILD_TAG}"
}
parameters {
booleanParam(
name: 'all_tests',
defaultValue: false,
description: 'Run tests for all components'
)
booleanParam(
name: 'deploy_commit',
defaultValue: false,
description: 'Deploy this commit to devnet'
)
}
stages {
stage('Setup') {
steps {
dir("${env.DOCKER_BUILD_DIR}/test/api-channel/") {
script {
def repoSharedDb = checkout scm
env["GIT_COMMIT"] = repoSharedDb.GIT_COMMIT
}
}
}
}
stage('Testing') {
when {
anyOf {
// Disable PR Testing
//changeRequest()
equals expected: true, actual: params.all_tests
}
}
environment {
COMPOSE_PROJECT_NAME="au_sg_api_channel_sg_endpoint"
}
stages {
stage('Setup') {
steps {
dir("${env.DOCKER_BUILD_DIR}/test/api-channel/") {
echo "Starting API Channel"
sh '''#!/bin/bash
# Create external network
if [[ -z "$(docker network ls --filter name=igl_local_devnet --quiet)" ]]; then
docker network create igl_local_devnet
fi
#Setup minio staging location
python pie.py -R
export COMPOSE_PROJECT_NAME=au_sg_api_channel_sg_endpoint
mkdir -p --mode=u+rwx,g+rwxs,o+rwx "${DOCKER_BUILD_DIR}/test/api-channel/docker/volumes/${COMPOSE_PROJECT_NAME}/var/minio-data/.minio.sys"
touch ${DOCKER_BUILD_DIR}/test/api-channel/docker/volumes/${COMPOSE_PROJECT_NAME}/var/minio-data/.minio.sys/format.json
python pie.py api.build
python pie.py api.start
export COMPOSE_PROJECT_NAME=au_sg_api_channel_au_endpoint
mkdir -p --mode=u+rwx,g+rwxs,o+rwx "${DOCKER_BUILD_DIR}/test/api-channel/docker/volumes/${COMPOSE_PROJECT_NAME}/var/minio-data/.minio.sys"
touch ${DOCKER_BUILD_DIR}/test/api-channel/docker/volumes/${COMPOSE_PROJECT_NAME}/var/minio-data/.minio.sys/format.json
python pie.py api.build
python pie.py api.start
sleep 30s
'''
}
}
}
stage('Run Testing') {
steps {
dir("${env.DOCKER_BUILD_DIR}/test/api-channel/") {
sh '''#!/bin/bash
export COMPOSE_PROJECT_NAME=au_sg_api_channel_au_endpoint
python pie.py api.test
'''
}
}
post {
always {
dir("${env.DOCKER_BUILD_DIR}/test/api-channel/") {
junit 'api/tests/*.xml'
}
}
}
}
}
post {
cleanup {
dir("${env.DOCKER_BUILD_DIR}/test/api-channel/") {
sh '''#!/bin/bash
python3 pie.py api.destroy
'''
}
}
}
}
stage('Deploy') {
when {
branch 'master'
}
steps {
build job: '../cotp-devnet/build-api-channel/master', parameters: [
string(name: 'branchref_apichannel', value: "${GIT_COMMIT}")
]
}
}
}
post {
cleanup {
cleanWs()
}
}
}