forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
107 lines (90 loc) · 3.86 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
#!groovy
def GIT_BRANCH = ''
def IMAGE_REF = ''
def IMAGE_TAG = ''
def NOTIFIER_IMAGE = 'argo-rest-notifier'
def VERSION = ''
def NAMESPACE = ''
def runUtilityCommand(buildCommand) {
// Run an arbitrary command inside the docker builder image
sh "docker run --rm " +
"-v ${pwd()}/dist/pkg:/root/go/pkg " +
"-v ${pwd()}:/root/go/src/github.com/cyrusbiotechnology/argo " +
"-w /root/go/src/github.com/cyrusbiotechnology/argo argo-builder ${buildCommand}"
}
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
sh 'git submodule update --init --recursive'
sh 'git rev-parse HEAD > git-sha.txt'
script {
GIT_COMMIT = readFile 'git-sha.txt'
GIT_SHA = git.getCommit()
IMAGE_REF=docker2.imageRef()
IMAGE_TAG=IMAGE_REF.split(':').last()
GIT_BRANCH = env.BRANCH_NAME.replace('/', '').replace('_', '').replace('-', '')
def baseVersionTag = readFile "VERSION"
baseVersionTag = baseVersionTag.trim();
VERSION = "${baseVersionTag}-cyrus-${GIT_BRANCH}"
println "Version tag for this build is ${VERSION}"
}
}
}
stage('build utility container') {
steps {
sh "docker build -t argo-builder -f Dockerfile-builder ."
}
}
stage('run tests') {
steps {
runUtilityCommand("go test ./...")
}
}
stage('build controller') {
steps {
runUtilityCommand("make controller")
sh "docker build -t workflow-controller:${VERSION} -f Dockerfile-workflow-controller ."
}
}
stage('build executor') {
steps {
runUtilityCommand("make executor")
sh "docker build -t argoexec:${VERSION} -f Dockerfile-argoexec ."
}
}
stage('build Linux and MacOS CLIs') {
steps {
runUtilityCommand("make cli CGO_ENABLED=0 LDFLAGS='-extldflags \"-static\"' ARGO_CLI_NAME=argo-linux-amd64")
runUtilityCommand("make cli CGO_ENABLED=0 LDFLAGS='-extldflags \"-static\"' ARGO_CLI_NAME=argo-darwin-amd64")
}
}
stage('push containers to GCR') {
steps {
script { docker2.push("workflow-controller:${VERSION}", ["workflow-controller:${VERSION}"]) }
script { docker2.push("argoexec:${VERSION}", ["argoexec:${VERSION}"]) }
}
}
stage('push CLI to artifactory') {
steps {
withCredentials([usernamePassword(credentialsId: 'Artifactory', usernameVariable: 'ARTI_NAME', passwordVariable: 'ARTI_PASS')]) {
runUtilityCommand("curl -u ${ARTI_NAME}:${ARTI_PASS} -T /root/go/src/github.com/cyrusbiotechnology/argo/dist/argo-darwin-amd64 https://cyrusbio.jfrog.io/cyrusbio/argo-cli/argo-mac-${VERSION}")
runUtilityCommand("curl -u ${ARTI_NAME}:${ARTI_PASS} -T /root/go/src/github.com/cyrusbiotechnology/argo/dist/argo-linux-amd64 https://cyrusbio.jfrog.io/cyrusbio/argo-cli/argo-linux-${VERSION}")
}
}
}
stage('Deploy') {
steps {
script {
if (GIT_BRANCH in ['rc', 'release', 'master_engineering']) {
NAMESPACE = k8s.getNamespaceFromBranch(GIT_BRANCH) ?: 'development'
k8s.updateImageTag(NAMESPACE, VERSION, 'gcr.io/cyrus-containers/argoexec', GIT_BRANCH)
k8s.updateImageTag(NAMESPACE, VERSION, 'gcr.io/cyrus-containers/workflow-controller', GIT_BRANCH)
}
}
}
}
}
}