hyperspec-ai / orion-ros2-reference

Project Orion is an open source initiative to democratize the development of intelligent data collection systems for autonomous vehicle software, infrastructure and data pipelines for creating high quality certified data sets for researchers. The project is driven by a committee established by industrial partners.
MIT License
3 stars 2 forks source link

orion-ros2-reference

CI/CD Setup Steps

Install Jenkins

  1. Create EC2 Instance with 200 G disk space from amazon console
    1.1 Make sure security group has 8080 accessible to all

  2. 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

  3. 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 -

  4. Then add the following entry in your /etc/apt/sources.list
    4.1 $deb https://pkg.jenkins.io/debian-stable binary/

  5. Run the following command to install jenkins package
    5.1 $sudo apt-get update -y
    5.2 $sudo apt-get install jenkins -y

  6. 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

  7. 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

  8. Open Jenkins web ui http://<publick ip>:8080/ and enter the password copied in previous step

  9. Install Suggested Plugins

  10. Access Jenkins UI at http://:8080/

----- This completes the Jenkins Installtion part ------

Install plugins and necessary packages to configure jobs

  1. 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

  2. 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

  3. Generate ssh keys and add them to github repo as deploy keys
    3.1 $ssh-keygen

    keep pressing enter to choose the default options

    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/

  4. 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

  5. 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

  6. 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

  7. 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