-
Notifications
You must be signed in to change notification settings - Fork 15
/
Jenkinsfile
90 lines (85 loc) · 2.1 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
@Library('jenkins.shared.library') _
pipeline {
agent {
label 'ubuntu_docker_label'
}
environment {
HELM_IMAGE = "infoblox/helm:3.2.4-5b243a2"
HELM="""docker run --rm \
-e AWS_REGION \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-v ${env.WORKSPACE}:/pkg \
-w /pkg \
${env.HELM_IMAGE}"""
GIT_DESCRIBE = sh(script: "git describe --always --long --tags", returnStdout: true).trim()
GIT_VERSION = "${env.GIT_DESCRIBE}-j${env.BUILD_NUMBER}"
}
stages {
stage("Prepare Build") {
steps {
prepareBuild()
}
}
stage("Push Images") {
when {
anyOf {
branch 'main'
branch 'ci'
}
}
steps {
withDockerRegistry([credentialsId: "dockerhub-bloxcicd", url: ""]) {
sh '''
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install -y golang-go
make docker-build docker-push
make -C test/apiserver push
'''
}
}
}
stage("Package Charts") {
steps {
withAWS(credentials: "CICD_HELM", region: "us-east-1") {
sh 'make package'
}
}
}
stage("Push Chart") {
when {
anyOf {
branch 'main'
branch 'ci'
}
}
steps {
dir("helm-charts") {
withAWS(credentials: "CICD_HELM", region: "us-east-1") {
sh '''\
for chart in konk*
do
chart_file=$chart-$GIT_VERSION.tgz
$HELM s3 push /pkg/$chart_file infobloxcto
cat << EOF > $WORKSPACE/$chart.properties
repo=infoblox-helm-dev
chart=$chart_file
messageFormat=s3-artifact
customFormat=true
EOF
done
'''.stripIndent()
}
}
archiveArtifacts artifacts: '*.properties'
archiveArtifacts artifacts: '*.tgz'
}
}
}
post {
success {
finalizeBuild('', getFileList("*.properties"))
}
}
}