-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
pipeline { | ||
agent none | ||
|
||
stages { | ||
stage('Checkout') { | ||
agent any | ||
steps { | ||
git branch: 'main', url: 'https://github.com/yoowonsuk/source-maven-java-spring-hello-webapp' | ||
} | ||
} | ||
stage('Build') { | ||
agent { | ||
docker { image 'maven:3-openjdk-8' } | ||
} | ||
steps { | ||
sh 'mvn clean package -DskipTests=true' | ||
} | ||
} | ||
stage('Test') { | ||
agent { | ||
docker { image 'maven:3-openjdk-8' } | ||
} | ||
steps { | ||
sh 'mvn test' | ||
} | ||
} | ||
stage('Build Docker Image') { | ||
agent any | ||
steps { | ||
sh 'docker image build -t hellotomcat1 .' | ||
} | ||
} | ||
stage('Tag Docker Image') { | ||
agent any | ||
steps { | ||
sh 'docker image tag hellotomcat1 rkddkwlrhdiddl/hellotomcat1:v1' | ||
} | ||
} | ||
stage('Publish Docker Image') { | ||
agent any | ||
steps { | ||
withDockerRegistry(credentialsId: 'docker-hub-token', url: 'https://index.docker.io/v1/') { | ||
sh 'docker image push rkddkwlrhdiddl/hellotomcat1:v1' | ||
} | ||
} | ||
} | ||
stage('Run Docker Container') { | ||
agent { | ||
docker { | ||
image 'rkddkwlrhdiddl/jenkins-ansible' | ||
args '-u 0:0 -e DOCKER_HOST=tcp://172.31.30.114:2375' | ||
} | ||
} | ||
steps { | ||
ansiblePlaybook(playbook: 'docker-container-deploy.yaml') | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
- hosts: localhost | ||
connection: local | ||
|
||
tasks: | ||
- name: Create & Start Container | ||
docker_container: | ||
name: myweb | ||
image: "rkddkwlrhdiddl/hellotomcat1:{{lookup('env', 'BUILD_NUMBER')}}" | ||
state: started | ||
ports: | ||
- "80:8080" |