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.
Build Pipeline
Second step is to install the Build Pipeline plugin and create the pipeline.
Run the pipeline. This is how the pipeline would look like.
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.