-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
90 lines (89 loc) · 2.24 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('hub-jenkins-shared') _
pipeline {
agent any
environment {
ECR = '223221345407.dkr.ecr.us-east-1.amazonaws.com'
KUBECONFIG = './.kube/config' // kube config is set in the workspace so all the containers can use it
KUBECFG = credentials('KUBECFG')
}
options {
timeout(time: 30, unit: 'MINUTES')
}
stages {
stage('startup') {
when { anyOf { branch 'master' } }
steps {
sh "echo hi"
}
}
stage('create environment variables') {
agent {
dockerfile {
reuseNode true
dir 'images/nodejs'
}
}
steps {
script {
env.DOMAIN = 'dev.hub.geocloud.com'
}
sh 'echo DOMAIN = $DOMAIN'
sh 'printenv'
}
}
stage('build image') {
when { anyOf { branch 'master' } }
agent {
dockerfile {
reuseNode true
dir 'images/docker'
args "-v /var/run/docker.sock:/var/run/docker.sock"
}
}
steps {
sh "docker build -t ${env.ECR}/hubbot_temp:${env.GIT_COMMIT} -t ${env.ECR}/hubbot_temp:latest ."
}
}
stage('push image') {
when { anyOf { branch 'master' } }
agent {
dockerfile {
reuseNode true
dir 'images/aws-cli'
args '-v /var/run/docker.sock:/var/run/docker.sock'
}
}
steps {
sh "eval \$(aws ecr --region us-east-1 get-login | sed 's|https://||')"
sh "docker push ${env.ECR}/hubbot_temp:latest"
sh "docker push ${env.ECR}/hubbot_temp:${env.GIT_COMMIT}"
}
}
stage('Deploy to Dev') {
when { anyOf { branch 'master' } }
options {
timeout(time: 5, unit: 'MINUTES')
}
agent {
docker {
reuseNode true
image 'esridc/kubeutils:latest'
}
}
steps {
script {
kubecfg{} // creates active clusters' kubeconfig and downloads certs for them in the workspace kubeconfig
env.NAMESPACE = 'dev'
deployApp { // sets kubecontext and deploys
NAMESPACE = 'dev' // you cannot send the value from env var while calling a shared lib function
}
}
}
}
}
post {
always {
deleteDir()
}
}
}