forked from abutaha/aws-es-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
56 lines (51 loc) · 1.6 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
#!/usr/bin/env groovy
pipeline {
agent {
kubernetes {
label "jenkins-pods-${UUID.randomUUID().toString()}"
defaultContainer 'jnlp'
yamlFile '.ci/pod.yaml'
}
}
environment {
LABEL = "jenkins-pods-${UUID.randomUUID().toString()}"
DOCKER_REPOSITORY = "772592230491.dkr.ecr.eu-west-1.amazonaws.com"
DOCKER_TAG = "${env.TAG_NAME ?: env.GIT_COMMIT}"
DOCKER_IMAGE = "aws-es-proxy"
SLACK_CHANNEL = "#backend-builds"
}
options {
timestamps()
}
stages {
stage("Build") {
steps {
container('docker') {
sh """
docker build --tag ${DOCKER_IMAGE}:${env.DOCKER_TAG} . --network host
"""
}
}
}
stage("Push") {
when {
anyOf {
buildingTag()
branch "master"
}
}
steps {
container('docker') {
script {
docker.withRegistry("https://${DOCKER_REPOSITORY}", 'ecr:eu-west-1:ecr-credentials') {
sh """
docker tag ${DOCKER_IMAGE}:${env.DOCKER_TAG} ${DOCKER_REPOSITORY}/${DOCKER_IMAGE}:${env.DOCKER_TAG}
docker push ${DOCKER_REPOSITORY}/${DOCKER_IMAGE}:${env.DOCKER_TAG}
"""
}
}
}
}
}
}
}