JENKINS UNDERGROUND – Static Code Analysis | Deployment | Pipeline – PART 3

Static Code Analysis

Code Analysis is done to check the vulnerabilities in the code or to check any functional errors before deployment.

Code Analysis will reveal the future issues which may arise later on. For different languages there are different tools available. For eg. for Java we have Checkstyle, Cobertura, owasp, SonarQube Scanner and many more.

Here in this article we will scan the code and publish the result.

For scanning purpose we will use Checkstyle plugin and to publish the result we would be using Warnings Next Generation.

Now create new Job to scan the code. Checkstyle run as a part of maven lifecycle. Therefore, in the build section of the job select the maven settings and provide goal as checkstyle:checkstyle

To publish the result, select the desired option from post build action and build the code to see amazing graphs and warnings.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Build Pipeline

No alt text provided for this image

Second step is to install the Build Pipeline plugin and create the pipeline.

No alt text provided for this image

Run the pipeline. This is how the pipeline would look like.

No alt text provided for this image

Deploying The Artifact to a Server(Tomcat)

Once the above steps are completed, its time to deploy the artifact to the server. In this case we are deploying it on tomcat.

Its time to deploy our artifact to the tomcat. Tomcat is a service to host our Java application.

To deploy the artifacts we need to install a plugin – deploy to container and let’s create a job to deploy to the tomcat, which will be executed after code is built.

No alt text provided for this image
This is a Private IP

About the author

Deepak Sood

Deepak Sood is Lead Consultant in an IT firm holding expertise in Devops and QA Architecture with 8 years of experience.

His expertise is in building highly scalable frameworks. His skills include Java, Configuration Management, Containers, and Kubernetes.

Reach out to him using contact form.

View all posts