A sample Spring-based application
Find a file
2024-07-28 21:00:20 -04:00
.devcontainer Docker Container Run Build 2024-07-14 15:01:55 -04:00
.github/workflows Bump actions version to latest one (checkout * setup-java) 2024-01-23 12:22:42 +00:00
.mvn/wrapper Upgrade to Maven 3.9.7 2024-05-26 20:17:34 +02:00
.vs Docker Container Run Build 2024-07-14 15:01:55 -04:00
gradle/wrapper Upgrade to Gradle 8.7 2024-05-21 09:00:32 +02:00
grafana/provisioning/datasources add grafana and use promethesus as resource 2024-07-20 22:59:06 -07:00
src create branch for docker compose 2024-07-17 20:56:56 -07:00
.editorconfig Add Gradle files indentation to .editorconfig 2024-02-20 17:14:43 +00:00
.gitattributes Gradle wrapper files should have correct line endings 2024-02-29 14:35:20 +00:00
.gitignore Merge branch 'tautaus:FinalProject_main' into FinalProject_main 2024-07-28 14:37:05 -04:00
.gitpod.yml Add devcontainer and gitpod 2022-06-09 11:24:17 +01:00
automation.sh add owasp zap configurations and a report output 2024-07-20 20:23:32 -07:00
build.gradle Including CycloneDX for SBOM generation 2024-05-26 13:58:55 +01:00
docker-compose.yml Upgrade Dependencies 2024-05-25 17:00:35 +01:00
docker-compose_spring-petclinic.yml Latest Jenkins config 2024-07-28 14:34:20 -04:00
Dockerfile sajdiojqwoe 2024-07-28 20:59:08 -04:00
Dockerfile.jenkins add jenkins 2024-07-21 16:30:33 -07:00
gradlew Update dependency 2023-11-26 09:08:45 +00:00
gradlew.bat Bump gradle from 8.4 to 8.6 2024-02-29 14:35:20 +00:00
instructions.md update instructions 2024-07-22 16:02:39 -07:00
jenkins.yaml latest 2024-07-27 22:15:16 -04:00
Jenkinsfile Latest Jenkins config 2024-07-28 14:34:20 -04:00
LICENSE.txt Add license file 2021-10-05 16:49:36 +01:00
mvnw Upgrade to Maven 3.9.7 2024-05-26 20:17:34 +02:00
mvnw.cmd Upgrade to Maven 3.9.7 2024-05-26 20:17:34 +02:00
pom.xml create branch for docker compose 2024-07-17 20:56:56 -07:00
prometheus.yml create branch 2024-07-18 09:19:03 -07:00
readme.md Test push 2024-07-28 13:03:12 -04:00
readme_original.md update instructions 2024-07-22 16:02:39 -07:00
settings.gradle Make build work with Gradle 2021-12-16 11:25:09 +00:00
sonar-project.properties working sonarqube and sonarscanner 2024-07-27 18:27:47 -07:00

Getting started - Final Project

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

  1. 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
    
  2. 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
    
  3. Go to http://localhost:8081/

  4. Set up/install plugins

  5. 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

  1. Access Jenkins: Open http://localhost:8081 and set up Jenkins. Install the suggested plugins.

  2. Install Required Plugins:

    • Go to Manage Jenkins > Manage Plugins and install the following plugins:
      • Pipeline
      • Git
      • GitHub Integration
      • Docker Pipeline
  3. 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.
  4. 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.
  5. 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.

Steps 3: Running Static Analysis with Sonarqube

  1. Access Sonarqube: Open http://localhost:9000 and set up Sonarqube. Install the suggested plugins.

  2. Login to Sonarqube with the following user and password:

    • Username: admin
    • Password: admin (update password when prompted after login)
  3. Create project on Sonarqube

    • Navigate over to create project
    • set the following variables: Project display name = petclinic Project key = petclinic Main branch name = main
    • Choose the following option: global branch setting
    • Choose the following Analysis Method: Locally
    • Generate a project token
  4. Set sonar token

    • Copy the generated project token to clipboard

    • In your workspace, set the token environment variable (MY_SONAR_TOKEN)

          export MY_SONAR_TOKEN=<paste_token_here>
      
    
    
  5. Run static analysis

     ```bash
         docker run \                                              
             --rm \
             -e SONAR_HOST_URL=http://sonarqube:9000/ \
             -e SONAR_TOKEN=$MY_SONAR_TOKEN \
             -v "./:/usr/src" --network=spring-petclinic_custom-network\
             sonarsource/sonar-scanner-cli