-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfileDocker
More file actions
57 lines (55 loc) · 1.82 KB
/
JenkinsfileDocker
File metadata and controls
57 lines (55 loc) · 1.82 KB
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
pipeline {
agent any
environment {
service_name="authservice"
image_name ="acr/$service_name"
vpc_registry='556904013717.dkr.ecr.us-east-1.amazonaws.com'
mcaas_registry='752281881774.dkr.ecr.us-east-1.amazonaws.com'
}
tools {
// Use the EXACT name you gave it in Global Tool Configuration
maven 'Maven3'
}
stages {
stage('Test') {
steps {
sh 'mvn test' // Replace with your specific test command
}
}
stage('Build Docker image') {
steps {
sh """
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $mcaas_registry
docker build -t $image_name:$GIT_COMMIT .
"""
}
}
stage('Tagging docker image') {
steps {
sh "docker tag $image_name:$GIT_COMMIT $vpc_registry/$image_name:$GIT_COMMIT"
}
}
stage('Pushing to ECR') {
steps {
sh """
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $vpc_registry
docker push $vpc_registry/$image_name:$GIT_COMMIT
"""
}
}
stage('Update flux') {
steps {
build job: 'flux-update', parameters: [
[$class: 'StringParameterValue', name: 'FLUX_HASH', value: env.GIT_COMMIT],
[$class: 'StringParameterValue', name: 'FLUX_FILENAME', value: "${service_name}.yaml"]
]
}
}
}
post {
always {
// This captures the reports even if the build fails
junit '**/target/surefire-reports/*.xml'
}
}
}