-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
54 lines (43 loc) · 1.52 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
pipeline {
agent any
parameters {
gitParameter branchFilter: 'origin.*/(.*)', defaultValue: 'master', name: 'branch', type: 'PT_BRANCH', useRepository: 'https://github.com/parthw/weather-app'
}
options {
skipDefaultCheckout(true)
}
stages {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM', branches: [[name: "${params.branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'XXX', url: 'https://github.com/parthw/weather-app']]])
}
script {
env.commit_id = "${sh(script:'git rev-parse --short HEAD', returnStdout: true).trim()}"
}
}
stage("Build and Push") {
steps {
script {
docker.withRegistry('https://XXX', 'ecr-credXXXX') {
customImage = docker.build("XXXX/something/${env.JOB_NAME}:${env.commit_id}", ".")
customImage.push("latest")
customImage.push("${env.commit_id}")
}
}
}
}
stage('Deploy') {
steps {
sh "sed -i 's/VERSION/${env.commit_id}/g' deployment-configurations/deployment.yaml"
sh "kubectl apply -f deployment-configurations/deployment.yaml"
sh "kubectl apply -f deployment-configurations/hpa.yaml"
sh "kubectl apply -f deployment-configurations/service.yaml"
}
}
stage("Clean-up") {
steps {
sh 'docker image prune -a -f --filter "until=6h"'
}
}
}
}