-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
42 lines (35 loc) · 1.36 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
node {
// reference to maven
// ** NOTE: This 'maven-3.6.1' Maven tool must be configured in the Jenkins Global Configuration.
def mvnHome = tool 'Maven'
// holds reference to docker image
def dockerImage
// ip address of the docker private repository(nexus)
def dockerRepoUrl = "localhost:8083"
def dockerImageName = "hello-world-java"
def dockerImageTag = "${dockerRepoUrl}/${dockerImageName}:${env.BUILD_NUMBER}"
stage('Clone Repo') { // for display purposes
// Get some code from a GitHub repository
git 'https://github.com/cakeben/benops-app.git'
// Get the Maven tool.
// ** NOTE: This 'maven-3.6.1' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'Maven'
}
stage('Build Project') {
// build project via maven
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
}
stage('Build Docker Image') {
// build docker image
sh "whoami"
sh "ls -all /var/run/docker.sock"
sh "mv ./target/hello*.jar ./data"
dockerImage = docker.build("hello-world-java")
}
stage('Push Image to ECR'){
docker.withRegistry('https://995041947753.dkr.ecr.eu-west-2.amazonaws.com', 'ecr:eu-west-2:benops') {
docker.image('hello-world-java').push('latest')
}
}
}