-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.build
64 lines (54 loc) · 1.41 KB
/
Jenkinsfile.build
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
def checkout_scm() {
script {
checkout scm
}
}
def build_docker_image(name, tag) {
echo "Building container image"
script {
def revision = "ui-${tag}"
def repository = "https://${env.NAVIGATOR_ECR_REGISTRY}"
docker.withRegistry(repository) {
def image = docker.build("${name}:${revision}", "--build-arg SENTRY_AUTH_TOKEN=${env.SENTRY_AUTH_TOKEN} -f Dockerfile --progress=plain .")
image.push()
}
}
}
def tag = "${env.BRANCH_NAME}".toString().replaceAll("/", "_slash_")
pipeline {
options {
disableConcurrentBuilds()
}
agent any
environment {
SENTRY_AUTH_TOKEN = credentials('jenkins_navigator_ui_sentry_token')
}
stages {
stage('checkout_scm') {
steps {
checkout_scm()
}
}
stage('Login to ECR'){
steps{
sh "aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin ${env.NAVIGATOR_ECR_REGISTRY}"
}
}
stage('Build Image') {
steps {
build_docker_image('navigator-fjelltopp', tag)
}
}
}
post {
always {
cleanWs()
}
/* success {
slackSend (color: '#00FF00', message: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
} */
failure {
slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}