forked from seunayolu/maven-jenkins-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-ecr
53 lines (47 loc) · 1.4 KB
/
Jenkinsfile-ecr
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
pipeline {
agent any
tools {
maven "MAVEN3"
jdk "oracleJDK8"
}
environment {
awsEcrCreds = 'ecr:us-east-2:JenkinsAWSCLI'
awsEcrRegistry = "392102158411.dkr.ecr.us-east-2.amazonaws.com/devopsacad-d-image"
devopsacadEcrImgReg = "https://392102158411.dkr.ecr.us-east-2.amazonaws.com"
}
stages {
stage ('fetch code') {
steps {
script {
echo "Pull Source code from Git"
git branch: 'docker', url: 'https://github.com/seunayolu/maven-jenkins-project.git'
}
}
}
stage ('Build App') {
steps {
script {
echo "Building WAR with Maven"
sh 'mvn install -DskipTests'
}
}
}
stage ('Build Docker Image') {
steps{
script {
dockerImage = docker.build(awsEcrRegistry + ":$BUILD_NUMBER", "./Docker-files/app/multistage/")
}
}
}
stage ('Push Image to ECR') {
steps{
script {
docker.withRegistry (devopsacadEcrImgReg, awsEcrCreds) {
dockerImage.push ("$BUILD_NUMBER")
dockerImage.push ('latest')
}
}
}
}
}
}