Building Jenkins CICD pipeline with Slack Notification : Using Maven, Sonarqube, AWS ECS

Building Jenkins CICD pipeline with Slack Notification : Using Maven, Sonarqube, AWS ECS

Having a cicd pipeline to do your work reduces the stress significantly. So, recently I created a CICD project where I deployed the pipeline which Fetch's the code, Build it, test it using Maven, Analysis the code quality by Sonarqube, build's the Docker Image which is then uploaded to AWS ECR. Finally at the end it gets deployed by using AWS ECS.

At the end I integrated the project with Slack to get notified about the Jenkins Build status weather it was a success or failure.

Github Repo :- https://github.com/saurabh12571257/Vprofile_full_repo.git

AWS Server set-up :-

Create three server's :

  • Jenkins server : Access on port 8080

  • Sonar server : Access on port 80 allow Jenkins security group connection

  • Nexus server : Access on port 8081 allow Jenkins security group connection.

Integrating Maven in Jenkins

Step 1 :- Create a Jenkins Server.

Step 2 :- Log In and Go to Tools.

Step 3 :- In Tools section add maven version and assign a name to it.

Sonarqube integration with Jenkins

  • Step 1 :- Access your sonarqube account.

  • Step 2 :- Click on create a new project.

  • Step 3 :- Enter the display name and project key.

  • Step 4 :- In the next step Generate the token and copy it.

  • Step 5 :- Come to Jenkins->Manage->Credentials->System->Global Credential->Create Credentials->Choose for secret text give the name and paste the generated token in the Secret section.

  • Step 6 :- Come the Jenkins Tools section and in the SonarQube Scanner installations section add your requirements.

Step 7 :- Come the Jenkins System section and in the SonarQube Server add your server details with port number.

Nexus Repository integration :-

Nexus Repo integration has similar steps as Sonar server setup.

Just go in the repository section->create new repo -><Maven_name> Hosted one

For AWS ECR and ECS :-

Install AWS CLI and Docker Engine on Jenkins server.

Create an ECR repository.

Then go to ECS, create a ECS cluster and choose Fargate if possible because its a serverless service provided by AWS.

Create a Task definition in this you will create a role as Task execution role make sure after creating it you go to the role and give it the CloudWatchLogs permission.

Create a Service in ECS where you can choose how many containers you want and many more.

Slack notification Integration :-

Log in to the Slack webpage

Click on Create Workspace and Input the information required.

Now go to https://newworkspace-at28660.slack.com/apps/A0F7VRFKN-jenkins-ci and add click on add on Slack.

On Choose your channel option click your workspace and it may take some time to show up there so refresh and wait.

After this you will get your Secret text, so go to Jenkins and add it to the global credential.

At last go to System and Input the following information.

Plugins Needed are :-

Did you find this article valuable?

Support Saurabh's blog by becoming a sponsor. Any amount is appreciated!