Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3280

Setting Up Jenkins on Linux (Ubuntu 14.04)

$
0
0

The process of setting up a Jenkins CI server on a Linux machine is a little different compared to Windows. We set up Jenkins on a Windows server in the tutorial here. For this tutorial, we shall use a Linux server running the Ubuntu 14.04 distribution.

 

Note: You will need to have root access on the Linux server to successfully set up Jenkins.

 

 

1. Install Git

 

If you do not already have Git installed, you can install it by executing the following commands:

 

     sudo apt-get update

 

     sudo apt-get install git   

 

2. Install Jenkins

 

Follow the instructions here to install Jenkins on your system.

 

If Jenkins does not start automatically after installing, you can start it using the following command:

 

     sudo service jenkins start

 

3. Install Node and NPM

 

We will be using node packages in the build of the UI5 application. So we need to install Node.js and NPM. This is done using the following commands:

 

sudo apt-get update

 

sudo apt-get install nodejs

 

sudo apt-get install npm

 

To run Node, we will have to use the command 'nodejs' which is different from 'node' that is used on Windows. If you would like to use the 'node' command on Linux, you can do so by creating a symbolic link from 'nodejs' to 'node' in the /usr/bin folder as follows:

 

sudo ln -s /usr/bin/nodejs /usr/bin/node

4. Set up SSH Authentication for 'jenkins' User

 

Since Jenkins will be checking out code from the on-premise installation of GitHub, it needs to have the relevant access permissions to the repository. We do this by using an SSH key.

 

     sudo -s

 

Now, generate an SSH key and add it to your GitHub account. You can find the instructions for doing so here.

 

Ensure that you follow all the steps as the root user, since all the subsequent steps depend on the SSH key being added to the root user account.

5. Configure Jenkins to run as 'root' User Process

 

 


 

6. Install Required Plugins in Jenkins

 

The following plugins will need to be installed in Jenkins:

     a) Git Plugin for Jenkins

     b) GitHub Plugin for Jenkins

 

Go to Manage Jenkins > Manage Plugins > Available and look for the above plugins if they are not already installed, and install them. After installing the plugins, restart Jenkins.

 

Note: If you don't get a list of available plugins even after refreshing the list, you might first need to configure the proxy settings. To do this, go to Manage Jenkins > Manage Plugins > Advanced and enter the details as shown:

5.png

Click on 'Submit' and then click on 'Check Now' at the bottom-right corner of the page. You should now be able to see the list of all the available plugins in the 'Available' tab.

 

6. Set up Credentials in Jenkins

 

We now add our SSH credentials to Jenkins so that it can be authenticated when accessing GitHub.

 

Click on 'Credentials' on the Jenkins dashboard.

 

Select your domain. Select 'Global Credentials (unrestricted)' if you don't have domains set up yet.

 

Click on 'Add Credentials'

 

Enter the following details:

 

8.png

 

For the passphrase, enter the same passphrase that you used when setting up SSH authentication in Step 1. If you didn't use any passphrase, leave this field empty.

 

Click 'Ok'.

 

7. Add a Project in Jenkins

 

Select 'New Item' in the Jenkins dashboard, and create a new 'Freestyle project'. Enter your project details in the page that opens.

 

In the 'Source Code Management' section, select 'Git'.

 

Enter the URL of your repository in SSH format. It will be in the following format: git@github.wdf.sap.corp:<username>/<project_name>.git

 

You can get this SSH clone URL from the GitHub repository

 

10.png

 

For credentials, select 'root' from the dropdown box. These are the credentials that we set up in the previous step.

 

11.png

Click on 'Save' at the bottom of the page and then try to build your project. If everything was configured properly, Jenkins will clone your repository from GitHub and show that the build has passed.

 

Conclusion

You have now set up Jenkins on a Linux machine to communicate with your repository on GitHub. The next step is to configure your build to run unit tests and other tasks. You can see the article here for details on how to do this for a UI5 project. You can also configure Jenkins to run this build automatically when code is pushed to your repository on GitHub. Check out the tutorial on how to do this here.


Viewing all articles
Browse latest Browse all 3280

Trending Articles