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'
Then, I'll push it to the GitHub repository.
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
3. Build Now
Now, we are ready to execute the job. Let's add the command under Build Environment, then click Build Now!
Access the web server!
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!
Top comments (0)