-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-docker
63 lines (55 loc) · 1.57 KB
/
Jenkinsfile-docker
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
pipeline {
agent none
stages{
stage('Checkout'){
agent any
steps {
git branch: 'master', url: 'https://github.com/LeeHyeonHo-127/jenkins_webapp'
}
}
stage('Build'){
agent {
docker { image 'maven:3-openjdk-11' }
}
steps {
sh 'mvn clean package -DskipTests=true'
}
}
stage('Test') {
agent {
docker { image 'maven:3-openjdk-11' }
}
steps {
sh 'mvn test'
}
}
stage('Build Docker Image'){
agent any
steps {
sh 'docker image build -t tomcat-application:v1 . '
}
}
stage('Tag Docker Image'){
agent any
steps {
sh 'docker tag tomcat-application:v1 swethom3143/tomcat-application:v1'
}
}
stage('Publish Docker Image'){
agent any
steps {
withDockerRegistry(credentialsId: 'docker-hub-token', url: 'https://index.docker.io/v1/'){
sh 'docker push swethom3143/tomcat-application:v1'
}
}
}
stage('Run Docker Container'){
agent {
docker { image 'docker:dind' }
}
steps {
sh 'docker -H tcp://192.168.56.104:2375 container run --detach --name tomcap -p 80:8080 swethom3143/tomcat-application:v1'
}
}
}
}