Create EC2 Instance with 200 G disk space from amazon console
1.1 Make sure security group has 8080 accessible to all
SSH in to the instance and run following commands to install Java 8
2.1 $sudo apt update -y
2.2 $sudo apt install openjdk-8-jdk -y
Visit https://pkg.jenkins.io/debian-stable/ and copy the installation commands which are as below
3.1 $wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
Then add the following entry in your /etc/apt/sources.list
4.1 $deb https://pkg.jenkins.io/debian-stable binary/
Run the following command to install jenkins package
5.1 $sudo apt-get update -y
5.2 $sudo apt-get install jenkins -y
Start Jenkins Server as a Service and Enable at boot time
6.1 $sudo systemctl start jenkins
6.2 $sudo systemctl enable jenkins
6.3 $sudo systemctl status jenkins
Copy the initial admin password which will be asked when you launch web ui first time
7.1 $sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Open Jenkins web ui http://<publick ip>:8080/
and enter the password copied in previous step
Install Suggested Plugins
Access Jenkins UI at http://
----- This completes the Jenkins Installtion part ------
Ssh in to the instance give jenkins user sudo access without any password prompt
2.1 $sudo vi /etc/sudoers
Add the following line of code to the file. I added this after the root user in the User privilege specification section:
2.2 $jenkins ALL=(ALL) NOPASSWD:ALL
Switch to jenkins user
2.1 sudo su jenkins
2.2 cd //To take you to jenkins home directory which is /var/lib/jenkins for default jenkins installation
Generate ssh keys and add them to github repo as deploy keys
3.1 $ssh-keygen
3.2 $cat ~/.ssh/id_rsa.pub // or /var/lib/jenkins/.ssh/id_rsa.pub
3.3 Go to https://github.com/go360-io/orion-ros2-reference/settings
3.4 Click on Deploy Keys
in the left panel
3.5 Click on Add deploy key
and paste your public key here
3.6 Click on Webhooks
and add http://<publick ip>:8080/github-webhook/
Install necessary jenkins plugin
4.1 Login in to jenkins web ui
4.2 Go to Jenkins
-> Manage Jenkins
-> Manage Plugins
install these additional plugins
-> GitHub Integration Plugin
-> Pipeline: Multibranch with defaults
-> Slack Notification Plugin
Configure jenkins for Github integreation
5.1 Go to Jenkins
-> Manage Jenkins
-> Configure System
5.2 Scroll down and you will find the GitHub Pull Requests checkbox. In the Published Jenkins URL, add the repository link
-> https://github.com/go360-io/orion-ros2-reference
save changes
Configure Build pipeline
6.1 Go to Jenkins
-> New
6.2 Enter some name for the pipe line and choose type as Multibranch pipeline with defaults
6.3 Once created go to Configure
6.4 Scroll down to Build Configuration
choose By default jenkinsfile
and enter script id as orian-jenkins-config
(or whatever you choose you need to save the config file with same name/id)
6.5 check: Run default Jenkinsfile within Groovy sandbox and save
6.6 Go to Manage Jenkins
->Managed files
6.7 Click Add a new config
Choose Type as Groovy file
and give id as orian-jenkins-config
(Or whatever id you configured in the job in step 6.4)
6.8 Copy the contents from the file ./jenkins/orian-jenkins-config.groovy here and save
Configure slack notification (Optional)
7.1 Create a public channel say orion-ci-cd-notification
7.2 Go to channel settings
and Add an app
7.3 Choose Jenkins CI
7.4 Once select it will generate a token
for you
7.5 Go to Jenkins
-> Manage Jenkins
-> Configure System
7.6 Scroll down to Slack
-> Enter your workspace
name
-> Credentials-> type secret text
and use the token
generated by slack
-> Default Channel: orion-ci-cd-notifications
(or whatever you named your public channel)
-> Click Test Connection
to send a test notification
-> Uncomment notifyBuild()
function call in the orian-jenkins-config file