forked from infobloxopen/migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
68 lines (65 loc) · 1.43 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
// This library defines the isPrBuild, prepareBuild and finalizeBuild methods
@Library('jenkins.shared.library') _
pipeline {
agent {
label 'ubuntu_docker_label'
}
tools {
go "Go 1.17"
}
options {
checkoutToSubdirectory('src/github.com/infobloxopen/migrate')
}
environment {
GOPATH = "$WORKSPACE"
DIRECTORY = "src/github.com/infobloxopen/migrate"
}
stages {
stage("Setup") {
steps {
// prepareBuild is one of the Secure CICD helper methods
prepareBuild()
}
}
stage("Unit Tests") {
steps {
dir("$DIRECTORY") {
// sh "make test"
}
}
}
stage("Build Image") {
// only build images on trunk builds. An alternate approach
// when { branch 'main' } or when { anyOf { branch "main", branch "develop", "ib" } }
when {
expression { ! isPrBuild() }
}
steps {
withDockerRegistry([credentialsId: "${env.JENKINS_DOCKER_CRED_ID}", url: ""]) {
dir("$DIRECTORY") {
sh "make build"
}
}
}
}
}
post {
success {
// finalizeBuild is one of the Secure CICD helper methods
dir("$DIRECTORY") {
finalizeBuild(
sh(
script: 'make list-of-images',
returnStdout: true
)
)
}
}
cleanup {
dir("$DIRECTORY") {
sh "make clean || true"
}
cleanWs()
}
}
}