mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 14:55:50 +00:00
A sample Spring-based application
.devcontainer | ||
.github/workflows | ||
.mvn/wrapper | ||
.vs | ||
gradle/wrapper | ||
grafana/provisioning/datasources | ||
src | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitpod.yml | ||
automation.sh | ||
build.gradle | ||
docker-compose.yml | ||
docker-compose_spring-petclinic.yml | ||
Dockerfile | ||
Dockerfile.jenkins | ||
gradlew | ||
gradlew.bat | ||
instructions.md | ||
jenkins.yaml | ||
Jenkinsfile | ||
LICENSE.txt | ||
mvnw | ||
mvnw.cmd | ||
pom.xml | ||
prometheus.yml | ||
readme.md | ||
readme_original.md | ||
settings.gradle |
Getting started
Running a build pipeline
docker-compose -f docker-compose_spring-petclinic.yml up -d
Go to the following locations:
Stopping a build pipeline
docker-compose -f docker-compose_spring-petclinic.yml down
Troubleshooting a container
See an event in a running container:
docker logs <container-id>
docker logs spring-petclinic-petclinic-1
Run terminal in a running container:
docker exec -it <container-id> bash
docker exec -it spring-petclinic-petclinic-1 bash
Setting up Jenkins
Steps 1: Set up Jenkins in Docker
-
Create a DockerFile with the following content:
FROM jenkins/jenkins:lts USER root RUN apt-get update && apt-get install -y docker.io USER jenkins
-
Build and Run Jenkins:
docker build -t my-jenkins jenkins/ docker run -d --name jenkins --network devsecops-network -p 8081:8081 -v jenkins_home:/var/jenkins_home my-jenkins
-
Go to http://localhost:8081/
-
Set up/install plugins
-
When asked for a password, run the following command:
docker exec b946b28cf4b3ce018871fa319494d7add5e1d6806ee3a2e05bb6262c57a8b3a1 cat /var/jenkins_home/secrets/initialAdminPassword
Access Jenkins at: http://localhost:8081/jenkins
Steps 2: Create Jenkins Pipeline
-
Access Jenkins: Open http://localhost:8081 and set up Jenkins. Install the suggested plugins.
-
Install Required Plugins:
- Go to Manage Jenkins > Manage Plugins and install the following plugins:
- Pipeline
- Git
- GitHub Integration
- Docker Pipeline
- Go to Manage Jenkins > Manage Plugins and install the following plugins:
-
Create a New Pipeline Job:
- Go to Jenkins Dashboard.
- Click on New Item.
- Enter a name for your pipeline (e.g., Spring PetClinic Pipeline).
- Select Pipeline and click OK.
-
Configure the Pipeline:
- In the pipeline configuration, scroll down to the Pipeline section.
- Set Definition to Pipeline script.
- Write the script to configure the Pipeline.
-
Run the Pipeline:
- Save the Pipeline configuration by clicking Save.
- Go back to the Jenkins dashboard.
- Select your pipeline job.
- Click on Build Now to run the pipeline.