Published On: August 7th, 20233.2 min read

Jenkins is an open-source automation server that automates the tedious technical tasks related to software delivery and continuous integration. Jenkins is Java-based and can be installed from Ubuntu packages or by downloading and running its web application archive (WAR) file, a collection of files that make up a complete web application to run on a server.

Installing Jenkins

The Jenkins version that comes with the standard Ubuntu packages frequently lags behind the most recent release from the project itself. Use the project-maintained packages to install Jenkins if you want to be certain you have the most recent fixes and features. The repository key should first be added to your system

The Jenkins version that comes with the standard Ubuntu packages frequently lags behind the most recent release from the project itself. Use the project-maintained packages to install Jenkins if you want to be certain you have the most recent fixes and features. The repository key should first be added to your system.

Copy to Clipboard

 

The gpg –dearmor command is used to convert the key into a format that apt recognizes. Next, let’s append the Debian package repository address to the server’s sources.list:

Copy to Clipboard

 

The [signed-by=/usr/share/keyrings/jenkins.gpg] portion of the line ensures that apt will verify files in the repository using the GPG key that you just downloaded.

After both commands have been entered, run apt update so that apt will use the new repository.
sudo apt update

Finally, install Jenkins and its dependencies.

Copy to Clipboard

 

Starting Jenkins:

Now that Jenkins is installed, start it by using systemctl:

Copy to Clipboard

 

Since systemctl doesn’t display status output, we’ll use the status command to verify that Jenkins started successfully.

Copy to Clipboard

 

Setting up Jenkins:

To set up your installation, visit Jenkins on its default port, 8080, using your server domain name or IP address: http://your_server_ip_or_domain:8080

You should receive the Unlock Jenkins screen, which displays the location of the initial password:

In the terminal window, use the cat command to display the password:

Copy to Clipboard

Copy the 32-character alphanumeric password from the terminal and paste it into the Administrator password field, then click Continue.

The next screen presents the option of installing suggested plugins or selecting specific plugins:

CI/CD Automation for GitHub with Jenkins | Nascenia Blog

We’ll click the Install suggested plugins option, which will immediately begin the installation process.

When the installation is complete, you’ll be prompted to set up the first administrative user. It’s possible to skip this step and continue as admin using the initial password from above, but we can also create the user.

After confirming the appropriate information, click Save and Finish. You’ll receive a confirmation page confirming that “Jenkins is Ready!”:

Jenkins Dashboard | Tech Blog | Nascenia

Click Start using Jenkins to visit the main Jenkins dashboard:

Jenkins Dashboard | Nascenia Tech blog

Integration with Jenkins:

  1. Click on New Item from Dashboard.
  2. Enter an iten name you like, choosing Freestyle project.
  3. Provide any description. Save.
  4. From the Build Steps, add Execute Shell.
  5. Type.
     
    Copy to Clipboard
     
    username>, <personal_token>, <repo_link>, <repo_dir>, <destination_to_keep_repo> should be changed according to your needs.
  6. Save configuration
  7. From terminal, type:

    Copy to Clipboard
  8. We can add more scripts in Build Steps to automate and also in Post-build Actions.
  9. Go back to jenkins and click on Build Now.

Conclusion

In this tutorial, we set up Jenkins to keep an eye on a GitHub project and automatically test any updated commits. Jenkins fetches code from the repository and launches isolated Docker containers to carry out the build and testing processes. By including extra instructions in the same Jenkinsfile, the generated code can be deployed or saved.

Contributor:  Utshab Kumar Ghosh, Software Engineer, Nascenia

Share it, Choose Your Platform!

More to Explore

The Quest for Knowledge Continues. Fuel Your Curiosity.