mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
mypetclinic.sh stop fix
This commit is contained in:
parent
1520aa2128
commit
da1ca5f3f4
3 changed files with 30 additions and 27 deletions
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
|
@ -25,6 +25,8 @@ node {
|
|||
timeout(time: 10, unit: 'MINUTES') {
|
||||
sh """ #!/bin/bash
|
||||
mvn test surefire-report:report
|
||||
|
||||
echo 'surefire report generated in /target/site/surefire-report.html'
|
||||
"""
|
||||
} // timeout
|
||||
} // stage: unittest
|
||||
|
@ -32,7 +34,9 @@ node {
|
|||
stage ("checkStyle") {
|
||||
timeout(time: 2, unit: 'MINUTES') {
|
||||
sh """ #!/bin/bash
|
||||
mvn validate
|
||||
mvn checkstyle:checkstyle
|
||||
|
||||
echo 'checkstyle report generated in /target/site/checkstyle.html'
|
||||
"""
|
||||
} // timeout
|
||||
} // stage: validate
|
||||
|
@ -41,6 +45,8 @@ node {
|
|||
timeout(time: 2, unit: 'MINUTES') {
|
||||
sh """ #!/bin/bash
|
||||
mvn jacoco:report
|
||||
|
||||
echo 'Jacoco report generated in /target/site/jacoco/index.html'
|
||||
"""
|
||||
} // timeout
|
||||
} // stage: Jacoo
|
||||
|
@ -49,8 +55,6 @@ node {
|
|||
stage ("Docker") {
|
||||
stage('build') {
|
||||
sh """ #!/bin/bash
|
||||
# docker login
|
||||
# docker image build -f Dockerfile -t petclinic:cli .
|
||||
docker image build -f Dockerfile -t ${projectName}:${env.BUILD_ID} .
|
||||
"""
|
||||
} // stage: build
|
||||
|
@ -77,7 +81,7 @@ node {
|
|||
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'DOCKER_REGISTRY_PWD', usernameVariable: 'DOCKER_REGISTRY_USER')]) {
|
||||
sh """ #!/bin/bash
|
||||
docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PWD
|
||||
echo 'Login success'
|
||||
echo 'Login success...'
|
||||
|
||||
docker push krishnamanchikalapudi/${projectName}:${env.BUILD_ID}
|
||||
docker push krishnamanchikalapudi/${projectName}:latest
|
||||
|
@ -88,23 +92,13 @@ node {
|
|||
} // withCredentials: dockerhub
|
||||
} // stage: push
|
||||
stage('clean') {
|
||||
parallel pruneImage: {
|
||||
sh """ #!/bin/bash
|
||||
docker image prune -f --filter until=1h
|
||||
"""
|
||||
}, pruneContainer: {
|
||||
sh """ #!/bin/bash
|
||||
docker container prune -f --filter until=1h
|
||||
"""
|
||||
}, pruneSystem: {
|
||||
sh """ #!/bin/bash
|
||||
docker system prune -f --filter until=1h
|
||||
"""
|
||||
}, rmiImages: {
|
||||
sh """ #!/bin/bash
|
||||
docker rmi -f ${projectName}
|
||||
"""
|
||||
}
|
||||
sh """ #!/bin/bash
|
||||
docker image ls
|
||||
echo 'Deleting local images...'
|
||||
docker rmi -f $(docker images -aq)
|
||||
|
||||
docker image ls
|
||||
"""
|
||||
} // stage: clean
|
||||
} // stage: docker
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ clean() {
|
|||
docker image prune -a -f --filter "until=1h"
|
||||
docker container prune -f --filter "until=1h"
|
||||
docker system prune -f --filter "until=1h"
|
||||
docker rmi -f $(docker images -aq)
|
||||
}
|
||||
startContainer() {
|
||||
printf "\n -------- Downloading container: ${containerName} -------- \n "
|
||||
|
@ -32,16 +33,18 @@ startContainer() {
|
|||
docker run -d --name ${containerName} -p ${exposePort}:8080 ${orgName}/${imageName}:latest
|
||||
|
||||
sleep 5
|
||||
open -a 'Google Chrome' $WEB_ADDR
|
||||
|
||||
sleep 2
|
||||
docker logs -f $containerId &
|
||||
docker logs -f ${containerName} &
|
||||
|
||||
# xdg-open $WEB_ADDR # ubuntu
|
||||
# open 'Google Chrome' $WEB_ADDR # mac
|
||||
printf "\n ---------------------------------------------------------------- "
|
||||
printf "\n ---------- In Web Browser, open http://localhost:7080 ---------- "
|
||||
printf "\n ---------------------------------------------------------------- "
|
||||
}
|
||||
stopContainer() {
|
||||
printf "\n -------- Stop container: ${containerName} -------- \n "
|
||||
# docker container stop ${docker container ls -a | grep postgres | awk '{print $1}'}
|
||||
docker container stop $containerId -t 0
|
||||
docker stop $containerName -t 0
|
||||
docker rm -f $containerName
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ docker rmi -f mypetclinic
|
|||
- The container images from the Jenkin pipeline was uploaded to the [Docker repository](https://hub.docker.com/orgs/krishnamanchikalapudi/repositories)
|
||||
|
||||
## Docker image execution
|
||||
A few options are available to execute the Docker image [krishnamanchikalapudi/mypetclinic:latest](https://hub.docker.com/repository/docker/krishnamanchikalapudi/mypetclinic)
|
||||
A few options are available to execute the Docker image [krishnamanchikalapudi/mypetclinic:latest](https://hub.docker.com/r/krishnamanchikalapudi/mypetclinic/tags)
|
||||
### Option 1
|
||||
- Prerequisite
|
||||
- Device operating system: Mac or Linux
|
||||
|
@ -135,3 +135,9 @@ sudo setfacl -R -m user:jenkins:rwx /var/run/docker.sock
|
|||
|
||||
## License
|
||||
The Spring PetClinic sample application is released under version 2.0 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
||||
|
||||
## References
|
||||
- [Dockerfile reference](https://docs.docker.com/reference/dockerfile/)
|
||||
- [Docker CLI reference](https://docs.docker.com/reference/cli/docker/)
|
||||
- [Jenkins Docs](https://www.jenkins.io/doc/)
|
Loading…
Reference in a new issue