The Ops Community

Cover image for A Simple Task To Execute With Jenkins Job
Nurul Ramadhona
Nurul Ramadhona

Posted on • Updated on

A Simple Task To Execute With Jenkins Job

On the previous section, we've created a job and connected with GitHub as SCM for the job. Now, we'll execute a simple task. How is it going?

1. Create Bash Script
Cause I'm still new with Jenkins. I don't want to make it too hard. So, here I'm going to create simple bash script just for running two commands to install web server and change the HTML code.

#!/bin/bash
sudo apt install apache2 -y
sudo bash -c 'echo "Hello World! Web 1" > /var/www/html/index.html'
Enter fullscreen mode Exit fullscreen mode

Then, I'll push it to the GitHub repository.

Web Server 1

2. Add Rule To The Security Group
As I mentioned before, because we host the Jenkins on cloud. We need to create new rule for additional setting. For example: in this case we're going to install web server, then port 80 should be allowed for incoming traffic. So, here I add new rule to the existing security group that we used.

$ aws ec2 authorize-security-group-ingress --group-name jenkins --protocol tcp --port 80 --cidr 0.0.0.0/0
Return: true
Enter fullscreen mode Exit fullscreen mode

3. Build Now
Now, we are ready to execute the job. Let's add the command under Build Environment, then click Build Now!

Web Server 2

Web Server 3

Web Server 4

Web Server 5

Access the web server!

Web Server 6

Alright, that's it for now! Any feedback are very welcome and thank you for coming. Follow me to get notified when new post is published by me! Thank you.

Let's continue to the next part!

Discussion (0)