Skip to content
 
 

Repository files navigation

Week3 - JenkinsCI

image

Tools involved:

  1. Github
  2. Jenkins
  3. docker
  4. JFrog
  5. ubuntu machine to host
  6. docker for windows To setup the infra I first installed Jenkins on ubuntu machine. Below is the link for reference:- https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-20-04 Once the Jenkins was up, I installed all the relevant plugins , docker, artifactory, git etc Then I installed docker on ubuntu machine below is the link for reference https://docs.docker.com/engine/install/ubuntu/ Then created a free cloud account for JFrog artifactory.

Once the infrastructure was up and running, I followed the below steps to start with the assignment.

  1. First, logged into GitHub from any web browser. Then forked the Spring PetClinic repository (the example application we’ll use).

  2. Cloned the spring-petclinic repo on my local repo. for eg:- prakan2/JFrog-assesment (github.com) $ git clone https://github.com/shanemacbride/spring-petclinic.git $ cd spring-petclinic

    1. Provided maven and gradle read write permissions . sh "chmod 755 gradlew" sh "chmod 755 mvnw"
  3. Executed the maven clean, maven install steps to build and test the application. sh "./mvnw clean" sh "./mvnw install”

  4. Once the above steps gets executed successfully, we are good to package our application run
    sh "./mvnw package

  5. The package generates a .jar file in the target folder as spring-petclinic-2.6.0-SNAPSHOT.jar

  6. The jar file can be run manually on the local machine as java -jar target/*.jar

All the above steps are included in the Jenkinsfile and committed to the git repo . JFrog-assesment/Jenkinsfile at main · prakan2/JFrog-assesment (github.com)

Once the image gets built it creates an image with the help of Dockerfile which is part of the Jenkinsfile. JFrog-assesment/Dockerfile at main · prakan2/JFrog-assesment (github.com) And the dockerfile is also committed to the git repo.

Once the image assessment_jenkins is generated with the help of docker you can check for the image in two ways

  1. docker ps image

  2. in the docker for windows image

Once we have the image created we can upload the image into the JFrog artifactory with the following steps :-

  1. Generate a token in the Jfrog instance and also create a private docker repo inside Jfrog. Here it is qwerty

  2. docker login to the Jfrog instance image

  3. check for the available images via docker ps command image

  4. tag the available image if not already
    image

  5. push the image into the jfrog instance
    image

  6. once pushed we can check it on the Jfrog if the image is available
    image

Finally the image build can be run in two ways :-

  1. docker run command docker run --name jekinsci_assessment -d -p 8080:8080 jenkinsci:latest
  2. via docker desktop . check on the image -> click on run -> provide a container name along with the ports to expose -> click submit . image

This will launch the spring-clinic web port on port 8080. image

Jenkins Job for assessment with github webhook enabled image

The source code is on the below repository :- https://github.com/prakan2/JenkinsCI.git

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages