Skip to content

Commit

Permalink
Added jenkins CI file integration
Browse files Browse the repository at this point in the history
  • Loading branch information
alitariq4589 committed Sep 9, 2024
1 parent 7d516fc commit 9914a77
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 59 deletions.
4 changes: 2 additions & 2 deletions source/ci_hosting.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
======================================================
Hosting a Continuous Integration (CI) Project at a Lab
Hosting Continuous Integration (CI) for RISC-V
======================================================

Hosting a continuous integration project at a lab means providing RISC-V hardware or emulated compute instances as CI runners/agents for public use. CI compute instances can be integrated with version control systems such as GitHub, GitLab, etc. and can automate the build process of the source code for developers.

Following version control systems currently support RISC-V CI:
Following platforms currently support RISC-V CI:

#. Jenkins
#. GitLab
Expand Down
61 changes: 4 additions & 57 deletions source/hosting_jenkins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,9 @@
Hosting RISC-V CI through Jenkins
==================================

This page describes how users can host RISC-V CI via Jenkins. For hosting CI through Jenkins, follow the steps described below.

Installing Jenkins
===================
.. toctree::
:maxdepth: 2

Jenkins install instructions are given at `this link <https://www.jenkins.io/doc/book/installing/>`_.

If you wish to build Jenkins from source, the repository is available at `<https://github.com/jenkinsci/jenkins>`_

Adding RISC-V agents in Jenkins
===============================

Agents are the compute instances in Jenkins on which CI builds are run.
Once Jenkins is installed, the next step is to add RISC-V agents in Jenkins. They are also referred to as slaves, build executors, or runners.

Make sure that Jenkins Master (the compute instance on which Jenkins web server is running) is accessible by the RISC-V compute instance you wish to add as a slave.

*For the sake of simplicity, it is assumed that RISC-V compute instances have Linux operating installed on them (preferably Ubuntu) and are accessible through SSH*

Install prerequisites
---------------------

Compute instances need OpenJDK 17 or newer installed on them to be hosted on Jenkins.

.. code::
sudo apt install openjdk-17-jdk
Set up agent in Jenkins
-----------------------

* In the Jenkins web server, go to :code:`Build Executor Status > New Node`

.. image:: assets/hosting_jenkins_1.png

.. image:: assets/hosting_jenkins_2.png

* Add a Node name (this will be displayed in the build executor list) and select Permanent Agent

* Add a suitable description for users who will be using that compute instance

.. image:: assets/hosting_jenkins_3.png

* Add the number of executors (this indicates how many builds can run concurrently)
* Change :code:`Launch method` to :code:`Launch agents via SSH` since our agent is accessible via SSH
* In :code:`Host`, add the IP or URL which can be used to access the compute instance
* In :code:`Credentials`, click on :code:`Add` if you have not created the credentials yet and add the credentials :code:`Kind` as :code:`Username with password` (these are the credentials which you can use to SSH to your RISC-V compute instance)
* In :code:`Host Key Verification Strategy`, select :code:`Manually trusted key Verification strategy` and also check :code:`Require manual verification of initial connection`
* If you access the RISC-V compute instance through a port other than 22, click on :code:`Advanced` and enter :code:`Port`
* Leave other settings as is and click save

Once the settings are saved, you will see :code:`Trust SSH Host Key` on the left bar. Click on it and grant permission to use the compute instance to the Jenkins controller.

.. image:: assets/hosting_jenkins_4.png

.. image:: assets/hosting_jenkins_5.png

Now the Jenkins agent is added and can be used. For using Jenkins as mentioned above instance, use the name which you gave it at the start in your build pipelines of Jenkins.
setting_up_jenkins
writing_ci_pipeline_file
63 changes: 63 additions & 0 deletions source/setting_up_jenkins.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

Setting Up Jenkins
*******************

This page describes how users can host RISC-V CI via Jenkins. For hosting CI through Jenkins, follow the steps described below.

Installing Jenkins
===================

Jenkins install instructions are given at `this link <https://www.jenkins.io/doc/book/installing/>`_.

If you wish to build Jenkins from source, the repository is available at `<https://github.com/jenkinsci/jenkins>`_

Adding RISC-V agents in Jenkins
===============================

Agents are the compute instances in Jenkins on which CI builds are run.
Once Jenkins is installed, the next step is to add RISC-V agents in Jenkins. They are also referred to as slaves, build executors, or runners.

Make sure that Jenkins Master (the compute instance on which Jenkins web server is running) is accessible by the RISC-V compute instance you wish to add as a slave.

*For the sake of simplicity, it is assumed that RISC-V compute instances have Linux operating system installed on them (preferably Ubuntu) and are accessible through SSH*

Install prerequisites
---------------------

Compute instances need OpenJDK 17 or newer installed on them to be hosted on Jenkins.

.. code::
sudo apt install openjdk-17-jdk
Set up agent in Jenkins
-----------------------

* In the Jenkins web server, go to :code:`Build Executor Status > New Node`

.. image:: assets/hosting_jenkins_1.png

.. image:: assets/hosting_jenkins_2.png

* Add a Node name (this will be displayed in the build executor list) and select Permanent Agent

* Add a suitable description for users who will be using that compute instance

.. image:: assets/hosting_jenkins_3.png

* Add the number of executors (this indicates how many builds can run concurrently)
* Change :code:`Launch method` to :code:`Launch agents via SSH` since our agent is accessible via SSH
* In :code:`Host`, add the IP or URL which can be used to access the compute instance
* In :code:`Credentials`, click on :code:`Add` if you have not created the credentials yet and add the credentials :code:`Kind` as :code:`Username with password` (these are the credentials which you can use to SSH to your RISC-V compute instance)
* In :code:`Host Key Verification Strategy`, select :code:`Manually trusted key Verification strategy` and also check :code:`Require manual verification of initial connection`
* If you access the RISC-V compute instance through a port other than 22, click on :code:`Advanced` and enter :code:`Port`
* Leave other settings as is and click save

Once the settings are saved, you will see :code:`Trust SSH Host Key` on the left bar. Click on it and grant permission to use the compute instance to the Jenkins controller.

.. image:: assets/hosting_jenkins_4.png

.. image:: assets/hosting_jenkins_5.png

Now the Jenkins agent is added and can be used. For using Jenkins as mentioned above instance, use the name which you gave it at the start in your build pipelines of Jenkins.
46 changes: 46 additions & 0 deletions source/writing_ci_pipeline_file.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Writing a CI pipeline file for Jenkins
========================================

The CI pipeline used for Jenkins CI is called Jenkinsfile. Jenkinsfile can be of two types:

1. Scripted Jenkinsfile
2. Declarative Jenkinsfile


Jenkinfile Examples
===================

Following is an example of scripted jenkinfile.

.. code-block:: groovy
node{
stage('*** Phase 1 ***') {
//Using bash commands
sh '''#!/bin/bash
echo "Hello World !\n"
'''
}
}
The above jenkinsfile prints "Hello World !" on the console output. The :code:`node` indicates the build executor where you would like to run your build. If there is nothing written with :code:`node`, the build can run on any build executor.

The above jenkinsfile can be written in Declarative syntax as below:

.. code-block:: groovy
pipeline {
agent any
stages {
stage('*** Phase 1 ***') {
steps {
// Using bash commands
sh '''#!/bin/bash
echo "Hello World !\n"
'''
}
}
}
}

0 comments on commit 9914a77

Please sign in to comment.