-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-docker-ansible
66 lines (58 loc) · 1.68 KB
/
Jenkinsfile-docker-ansible
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
64
65
66
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('Docker Container Deploy to Docker Out of Docker with Ansible') {
agent {
docker {
image 'ghcr.io/c1t1d0s7/jenkins-ansible-agent'
args '-u 0:0 -e DOCKER_HOST=tcp://192.168.56.104:2375'
}
}
steps {
ansiblePlaybook(playbook: 'docker-container-deploy.yaml')
}
}
}
}