Step 1:
Launch an Ubuntu(22.04) t2.large instance
Install Jenkins on it.
To install Jenkins : Click here
Once Jenkins is up and running, you can access it by navigating to your EC2 instance’s public IP address followed by port 8080.
To get the password, type the following command,
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Step 2:
Create a channel Named Jenkins


Step 3:
Install the Jenkins CI app on Slack
Goto Settings & administration -> Manage apps and search Jenkins CI


Click on Add to Slack

Now choose your Slack channel and click on Add Jenkins CI integration

You will be redirected to new page
Follow the steps as described in the page to integrate slack with jenkins
Step 4:
Go to Jenkins Dashboard
Install Slack Notification plugin

Now go to Manage Jenkins –> Credentials –> Global
Select kind as Secret Text and provide your Slack integration token credential ID

Now click on Manage Jenkins again in the left navigation and then go to Configure system. Find the Slack section and add the following values:

Click on Test Connection

Click on Apply and Save
Step 5:
Now create a new Pipeline job and add this to the pipeline
def COLOR_MAP = [
'FAILURE' : 'danger',
'SUCCESS' : 'good'
]
pipeline{
agent any
stages {
stage('Hello'){
steps{
echo "Hello world"
}
}
}
post {
always {
echo 'Slack Notifications'
slackSend (
channel: '#channel name', #change your channel name
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} \n build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}"
)
}
}
}
You will get a Notification in Slack

