Help


Community tutorials and documentations

How to build a continuous integration strategy for your applications with Jenkins CI

How to build a continuous integration strategy for your applications with Jenkins CI

This page shows you how to use the Jenkins CI tool InstantApp on your C1 server.

Requirements

  • You have an account and are logged into cloud.scaleway.com
  • You have configured your SSH Key

Jenkins provides continuous integration services for software development.

There are five steps to deploy and configure the Jenkins InstantApp

  • Create and start a new C1 server using the Jenkins InstantApp
  • Configure Jenkins authentication
  • Deploy Jenkins workers
  • Create a Jenkins job for your application
  • Upgrade Jenkins

Step 1 - Create and start a new C1 server using the Jenkins instant app

Let’s begin by creating a new Jenkins server by using the Jenkins InstantApp. Click the “Create Server” button in the control panel.

Control Panel

You will land on the server-creation page where you must input basic information for your server and choose an image for your server.

Create server basic information

After inputting your server basic information, select the Jenkins application image for your server.
On the ImageHub tab, select Jenkins and click the “Create Server” button.

The server will be created with a ready to use Jenkins install.

Step 2 - Configure Jenkins authentication

Your Jenkins server is now started but everyone can access it. The next thing to do is to enable authentication so only authenticated users will be able to access it.

To access your Jenkins server in a browser, go to http://<your_server_ip>:8080. You will land on the default Jenkins homepage. Click “Manage Jenkins” in the left-side menu. You land on the Jenkins management page.

Manage Jenkins

On the top of this page a message notify you that the install is not secured and recommand you to setup security. Click the “Setup Security” button to begin the process.

Security Jenkins

  1. Select the Enable Security checkbox.
  2. In Access Control:
  3. Security Realm: Ensure that Jenkins’ own user database is checked and unselect Allow users to sign up to prevent user sign-up. That will use the Jenkins’s own user database and disable sign ups.
  4. Matrix-based security: Take care to apply the correct right for anonymous user. In my case I allow only read access for anonymous user.
  5. Save your changes

Signup Jenkins

Back to the Jenkins server base url http://<your_server_ip>:8080 and sign-up by filling-in the form. Once the form submitted, your account will be administrator of the Jenkins.

Step 3 - Deploy Jenkins workers

Now that we have a configured Jenkins server, we will spawn workers node AKA slave machines to perform our jobs. There are differents ways to add a slave node, you can check them out here.

Let’s setup a slave agent headlessly.

Configure node

On the Jenkins server create a new node:

  • click “Manage Jenkins” in the left-side menu
  • Select “Manage nodes”
  • click “New node” in the left-side menu
  • Name your node
  • Select “Launch slage agent via Java Web Start”
  • Save

Create a new C1 server using the Jenkins worker InstantApp. It spawns a server with git, subversion, mercurial, docker, java installed on it. Once the server is started, connect to it via ssh and execute the following command:

wget http://<your_server_ip>:8080/jnlpJars/slave.jar
java -jar slave.jar -jnlpUrl http://<your_server_ip>:8080/computer/node01/slave-agent.jnlp

Your slave will be connected to Jenkins automatically to Jenkins master.

Step 4 - Create a Jenkins job for your application

We will create our first dummy job that will perform an hello world.

On the Jenkins dashboard, click “New Item”, give it a name and select Freestyle project.

Jenkins Helloworld

Then, you land on the page to configure your job. For this job, I only execute the echo "Hello World!" command and set the job to run every hour.

Jenkins Command

Jenkins Schedule

Save your job and click on “Build Now”.

You can consult your job output by clicking the build id and “Console Output”.

Jenkins build id

Jenkins Output

Step 5 - Upgrade Jenkins

To upgrade Jenkins run the following command on the server

apt-get update
apt-get upgrade

Conclusion

Jenkins let you create and build your application with a huge flexibility. You can distribute your jobs to slave node to increase your build capacity. It also offers you the opportunity to add plugins that will help you to manage your builds. You can go deeper with the Official Jenkins documentation.

Discover a new cloud experience

Deploy SSD cloud servers in seconds.