-
Notifications
You must be signed in to change notification settings - Fork 132
/
Jenkinsfile
55 lines (48 loc) · 1.38 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
pipeline {
agent any
tools {
maven "3.8.5"
}
stages {
stage('Compile and Clean') {
steps {
// Run Maven on a Unix agent.
sh "mvn clean compile"
}
}
stage('deploy') {
steps {
sh "mvn package"
}
}
stage('Build Docker image'){
steps {
echo "Hello Java Express"
sh 'ls'
sh 'docker build -t anvbhaskar/docker_jenkins_springboot:${BUILD_NUMBER} .'
}
}
stage('Docker Login'){
steps {
withCredentials([string(credentialsId: 'DockerId', variable: 'Dockerpwd')]) {
sh "docker login -u anvbhaskar -p ${Dockerpwd}"
}
}
}
stage('Docker Push'){
steps {
sh 'docker push anvbhaskar/docker_jenkins_springboot:${BUILD_NUMBER}'
}
}
stage('Docker deploy'){
steps {
sh 'docker run -itd -p 8081:8080 anvbhaskar/docker_jenkins_springboot:${BUILD_NUMBER}'
}
}
stage('Archving') {
steps {
archiveArtifacts '**/target/*.jar'
}
}
}
}