How to install jenkins
How to install jenkins
Offline Installations
This section describes how to install Jenkins on a machine that does not have an internet connection.
To install Jenkins itself, download the appropriate war file and transfer it to your machine.
Prerequisites
Minimum hardware requirements:
1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)
Recommended hardware configuration for a small team:
50 GB+ of drive space
Comprehensive hardware recommendations:
For Windows operating system: Windows Support Policy
For Linux operating system: Linux Support Policy
Offline plugin installation
Offline plugin installations require additional effort due to dependency requirements.
The Plugin Installation Manager Tool is the recommended tool for offline plugin installation. It downloads user specified plugins and all dependencies of the user specified plugins. The Plugin Installation Manager Tool also reports available plugin updates and plugin security warnings. It is included in the official Jenkins Docker images. It is also used to install plugins as part of the Docker install instructions. Refer to the Gitter chat channel for questions and answers
If you want to transfer the individual plugins, you’ll need to retrieve all dependencies as well. There are several dependency retrieval scripts and tools on Github. For example:
Post-installation setup wizard
After downloading, installing and running Jenkins using one of the procedures above (except for installation with Jenkins Operator), the post-installation setup wizard begins.
This setup wizard takes you through a few quick «one-off» steps to unlock Jenkins, customize it with plugins and create the first administrator user through which you can continue accessing Jenkins.
Unlocking Jenkins
When you first access a new Jenkins instance, you are asked to unlock it using an automatically-generated password.
Browse to http://localhost:8080 (or whichever port you configured for Jenkins when installing it) and wait until the Unlock Jenkins page appears.
From the Jenkins console log output, copy the automatically-generated alphanumeric password (between the 2 sets of asterisks).
Note:
The command: sudo cat /var/lib/jenkins/secrets/initialAdminPassword will print the password at console.
On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.
Notes:
You can always access the Jenkins console log from the Docker logs (above).
The Jenkins console log indicates the location (in the Jenkins home directory) where this password can also be obtained. This password must be entered in the setup wizard on new Jenkins installations before you can access Jenkins’s main UI. This password also serves as the default administrator account’s password (with username «admin») if you happen to skip the subsequent user-creation step in the setup wizard.
Customizing Jenkins with plugins
After unlocking Jenkins, the Customize Jenkins page appears. Here you can install any number of useful plugins as part of your initial setup.
Click one of the two options shown:
If you are not sure what plugins you need, choose Install suggested plugins. You can install (or remove) additional Jenkins plugins at a later point in time via the Manage Jenkins > Manage Plugins page in Jenkins. |
The setup wizard shows the progression of Jenkins being configured and your chosen set of Jenkins plugins being installed. This process may take a few minutes.
Creating the first administrator user
Finally, after customizing Jenkins with plugins, Jenkins asks you to create your first administrator user.
When the Create First Admin User page appears, specify the details for your administrator user in the respective fields and click Save and Finish.
When the Jenkins is ready page appears, click Start using Jenkins.
Notes:
This page may indicate Jenkins is almost ready! instead and if so, click Restart.
If the page does not automatically refresh after a minute, use your web browser to refresh the page manually.
If required, log in to Jenkins with the credentials of the user you just created and you are ready to start using Jenkins!
How To Install Jenkins on Ubuntu 20.04
Introduction
When faced with repetitive technical tasks, finding automation solutions that work can be a chore. With Jenkins, an open-source automation server, you can efficiently manage tasks from building to deploying software. Jenkins is Java-based, 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.
In this tutorial we’ll install Jenkins on Ubuntu 20.04, start the development server and create an administrative user to get you started in exploring what Jenkins can do. While you’ll have a development-level server ready for use at the conclusion of this tutorial, to secure this installation for production, follow the guide How to Configure Jenkins with SSL Using an Nginx Reverse Proxy on Ubuntu 18.04.
Prerequisites
To follow this tutorial, you will need:
Step 1 — Installing Jenkins
The version of Jenkins included with the default Ubuntu packages is often behind the latest available version from the project itself. To ensure you have the latest fixes and features, use the project-maintained packages to install Jenkins.
First, add the repository key to the system:
Next, let’s append the Debian package repository address to the server’s sources.list :
After both commands have been entered, we’ll run update so that apt will use the new repository.
Finally, we’ll install Jenkins and its dependencies.
Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.
Step 2 — Starting Jenkins
Let’s start Jenkins by using systemctl :
Since systemctl doesn’t display status output, we’ll use the status command to verify that Jenkins started successfully:
If everything went well, the beginning of the status output shows that the service is active and configured to start at boot:
Now that Jenkins is up and running, let’s adjust our firewall rules so that we can reach it from a web browser to complete the initial setup.
Step 3 — Opening the Firewall
Note: If the firewall is inactive, the following commands will allow OpenSSH and enable the firewall:
Check ufw ’s status to confirm the new rules:
You’ll notice that traffic is allowed to port 8080 from anywhere:
With Jenkins installed and our firewall configured, we can complete the installation stage and dive into Jenkins setup.
Step 4 — Setting Up Jenkins
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 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:
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 we used above, but we’ll take a moment to create the user.
Note: The default Jenkins server is NOT encrypted, so the data submitted with this form is not protected. Refer to How to Configure Jenkins with SSL Using an Nginx Reverse Proxy on Ubuntu 20.04 to protect user credentials and information about builds that are transmitted via the web interface.
Enter the name and password for your user:
You’ll receive an Instance Configuration page that will ask you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name for your server or your server’s IP address:
After confirming the appropriate information, click Save and Finish. You’ll receive a confirmation page confirming that “Jenkins is Ready!”:
Click Start using Jenkins to visit the main Jenkins dashboard:
At this point, you have completed a successful installation of Jenkins.
Conclusion
In this tutorial, you installed Jenkins using the project-provided packages, started the server, opened the firewall, and created an administrative user. At this point, you can start exploring Jenkins.
When you’ve completed your exploration, follow the guide How to Configure Jenkins with SSL Using an Nginx Reverse Proxy on Ubuntu 20.04 to protect your passwords, as well as any sensitive system or product information that will be sent between your machine and the server in plain text to continue using Jenkins.
To learn more about what you can do using Jenkins, check out other tutorials on the subject:
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
Windows
The simplest way to install Jenkins on Windows is to use the Jenkins Windows installer. That program will install Jenkins as a service using a 64 bit JVM chosen by the user. Keep in mind that to run Jenkins as a service, the account that runs Jenkins must have permission to login as a service.
Prerequisites
Minimum hardware requirements:
1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)
Recommended hardware configuration for a small team:
50 GB+ of drive space
Comprehensive hardware recommendations:
For Windows operating system: Windows Support Policy
For Linux operating system: Linux Support Policy
Installation steps using Windows MSI installer
Refer to the Windows section of the Downloading Jenkins page to download either an LTS release or a weekly release of the Windows installer. After the download completes, open the Windows installer and follow the steps below to install Jenkins.
On opening the Windows Installer, an Installation Setup Wizard appears, Click Next on the Setup Wizard to start your installation.
Select the destination folder to store your Jenkins Installation and click Next to continue.
When Installing Jenkins, it is recommended to install and run Jenkins as an independent windows service using a local or domain user as it is much safer than running Jenkins using LocalSystem(Windows equivalent of root) which will grant Jenkins full access to your machine and services.
To run Jenkins service using a local or domain user, specify the domain user name and password with which you want to run Jenkins, click on Test Credentials to test your domain credentials and click on Next.
If you get Invalid Logon Error pop-up while trying to test your credentials, follow the steps explained here to resolve it. |
Specify the port on which Jenkins will be running, Test Port button to validate whether the specified port if free on your machine or not. Consequently, if the port is free, it will show a green tick mark as shown below, then click on Next.
The installation process checks for Java on your machine and prefills the dialog with the Java home directory. If the needed Java version is not installed on your machine, you will be prompted to install it.
Once your Java home directory has been selected, click on Next to continue.
Select other services that need to be installed with Jenkins and click on Next.
Click on the Install button to start the installation of Jenkins.
Additionally, clicking on the Install button will show the progress bar of installation, as shown below:
Once the installation completes, click on Finish to complete the installation.
Jenkins will be installed as a Windows Service. You can validate this by browsing the services section, as shown below:
Post-installation setup wizard
After downloading, installing and running Jenkins, the post-installation setup wizard begins.
This setup wizard takes you through a few quick «one-off» steps to unlock Jenkins, customize it with plugins and create the first administrator user through which you can continue accessing Jenkins.
Unlocking Jenkins
When you first access a new Jenkins instance, you are asked to unlock it using an automatically-generated password.
Browse to http://localhost:8080 (or whichever port you configured for Jenkins when installing it) and wait until the Unlock Jenkins page appears.
The initial Administrator password should be found under the Jenkins installation path (set at Step 2 in Jenkins Installation).
For default installation location to C:\Program Files\Jenkins, a file called initialAdminPassword can be found under C:\Program Files\Jenkins\secrets.
However, If a custom path for Jenkins installation was selected, then you should check that location for initialAdminPassword file.
Open the highlighted file and copy the content of the initialAdminPassword file.
On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.
Notes:
You can also access Jenkins logs in the jenkins.err.log file in your Jenkins directory specified during the installation.
The Jenkins log file is another location (in the Jenkins home directory) where the initial password can also be obtained. This password must be entered in the setup wizard on new Jenkins installations before you can access Jenkins’s main UI. This password also serves as the default administrator account’s password (with username «admin») if you happen to skip the subsequent user-creation step in the setup wizard.
Customizing Jenkins with plugins
After unlocking Jenkins, the Customize Jenkins page appears. Here you can install any number of useful plugins as part of your initial setup.
Click one of the two options shown:
If you are not sure what plugins you need, choose Install suggested plugins. You can install (or remove) additional Jenkins plugins at a later point in time via the Manage Jenkins > Manage Plugins page in Jenkins. |
The setup wizard shows the progression of Jenkins being configured and your chosen set of Jenkins plugins being installed. This process may take a few minutes.
Creating the first administrator user
Finally, after customizing Jenkins with plugins, Jenkins asks you to create your first administrator user.
When the Create First Admin User page appears, specify the details for your administrator user in the respective fields and click Save and Finish.
When the Jenkins is ready page appears, click Start using Jenkins.
Notes:
This page may indicate Jenkins is almost ready! instead and if so, click Restart.
If the page does not automatically refresh after a minute, use your web browser to refresh the page manually.
If required, log in to Jenkins with the credentials of the user you just created and you are ready to start using Jenkins!
Troubleshooting Windows installation
Invalid service logon credentials
When installing a service to run under a domain user account, the account must have the right to logon as a service. This logon permission applies strictly to the local computer and must be granted in the Local Security Policy.
Perform the following steps below to edit the Local Security Policy of the computer you want to define the вЂlogon as a service’ permission:
Logon to the computer with administrative privileges.
Open the Administrative Tools and open the Local Security Policy
Expand Local Policy and click on User Rights Assignment
In the right pane, right-click Log on as a service and select properties.
Click on the Add User or Group… button to add the new user.
In the Select Users or Groups dialogue, find the user you wish to enter and click OK
Click OK in the Log on as a service Properties to save changes.
After completing the steps above, try logging in again with the added user.
Jenkins on AWS
Jenkins is an open-source automation server that integrates with a number of AWS Services, including: AWS CodeCommit, AWS CodeDeploy, Amazon EC2 Spot, and Amazon EC2 Fleet. You can use Amazon Elastic Compute Cloud (Amazon EC2) to deploy a Jenkins application on AWS.
This tutorial walks you through the process of deploying a Jenkins application. You will launch an EC2 instance, install Jenkins on that instance, and configure Jenkins to automatically spin up Jenkins agents if build abilities need to be augmented on the instance.
In this tutorial, you will perform the following steps:
Create a key pair using Amazon EC2. If you already have one, you can skip to step 3.
Create a security group for your Amazon EC2 instance. If you already have one, you can skip to step 4.
Prerequisites
An AWS account. If you don’t have one, you can register here.
An Amazon EC2 key pair. If you don’t have one, refer to Creating a key pair.
Creating a key pair
Creating a key pair helps ensure that the correct form of authentication is used when you install Jenkins.
To create your key pair:
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ and sign in.
In the navigation pane, under NETWORK & SECURITY, select Key Pairs.
Select Create key pair.
For Name, enter a descriptive name for the key pair. Amazon EC2 associates the public key with the name that you specify as the key name. A key name can include up to 255 ASCII characters. It cannot include leading or trailing spaces.
For File format, select the format in which to save the private key.
For OpenSSH compatibility, select pem.
For PuTTY compatibility, select ppk.
Select Create key pair.
The private key file downloads automatically. The base file name is the name you specified as the name of your key pair, and the file name extension is determined by the file format you chose. Save the private key file in a safe place.
This is the only chance for you to save the private key file. |
If you use an SSH client on a macOS or Linux computer to connect to your Linux instance, run the following command to set the permissions of your private key file so that only you can read it.
If you do not set these permissions, you cannot connect to your instance using this key pair. For more information, refer to Error: Unprotected private key file. |
Creating a security group
A security group acts as a firewall that controls the traffic allowed to reach one or more EC2 instances. When you launch an instance, you can assign it one or more security groups. You add rules that control the traffic allowed to reach the instances in each security group. You can modify a security group’s rules any time, and the new rules take effect immediately.
For this tutorial, you will create a security group and add the following rules:
Allow inbound HTTP access from anywhere.
Allow inbound SSH traffic from your computer’s public IP address so you can connect to your instance.
To create and configure your security group:
Decide who may access your instance. For example, a single computer or all trusted computers on a network. For this tutorial, you can use the public IP address of your computer.
To find your IP address, use the check IP service tool from AWS3 or search for the phrase «what is my IP address» in any search engine.
If you connect through an ISP or from behind your firewall without a static IP address, you will need the range of IP addresses used by client computers. If you don’t know this address range, you can use 0.0.0.0/0 for this tutorial.
This is unsafe for production environments because it allows everyone to access your instance using SSH. |
Open the Amazon EC2 console by selecting EC2 under Compute.
In the left-hand navigation bar, select Security Groups, and then select Create Security Group.
In Security group name, enter WebServerSG or any preferred name of your choice, and provide a description.
Select your VPC from the list. You can use the default VPC.
On the Inbound tab, add the rules as follows:
Select Add Rule, and then select SSH from the Type list.
Under Source, select Custom, and in the text box, enter the IP address from step 1.
Select Add Rule, and then select HTTP from the Type list.
Select Add Rule, and then select Custom TCP Rule from the Type list.
Under Port Range, enter 8080.
For more information, refer to Security Groups in the Amazon EC2 User Guide for Linux Instances.
Launching an Amazon EC2 instance
Now that you have configured a key pair and security group, you can launch an EC2 instance.
To launch an EC2 instance:
Open the Amazon EC2 console by selecting EC2 under Compute.
From the Amazon EC2 dashboard, select Launch Instance.
The Choose an Amazon Machine Image (AMI) page displays a list of basic configurations called Amazon Machine Images (AMIs) that serve as templates for your instance. Select the HVM edition of the Amazon Linux AMI.
This configuration is marked Free tier eligible. |
On the Choose an Instance Type page, the t2.micro instance is selected by default. Verify this instance type is selected to stay within the free tier. Once chosen, you can select Review and Launch.
On the Review Instance Launch page, select Edit security groups.
On the Configure Security Group page:
Select Select an existing security group.
Select the WebServerSG security group that you created.
Select Review and Launch.
On the Review Instance Launch page, select Launch.
In the Select an existing key pair or create a new key pair dialog box, select Choose an existing key pair. Then select the key pair you created in the creating a key pair section above or any existing key pair you intend to use.
In the left-hand navigation bar, choose Instances to view the status of your instance. Initially, the status of your instance is pending. After the status changes to running, your instance is ready for use.
Installing and configuring Jenkins
Now that the Amazon EC2 instance has been launched, Jenkins can be installed properly.
In this step you will deploy Jenkins on your EC2 instance by completing the following tasks:
Connecting to your Linux instance
After you launch your instance, you can connect to it and use it the same way as your local machine.
Before you connect to your instance, get the public DNS name of the instance using the Amazon EC2 console.
Select the instance and locate Public DNS.
If your instance doesn’t have a public DNS name, open the VPC console, select the VPC, and check the Summary tab. If either DNS resolution or DNS hostnames is no, select Edit and change the value to yes. |
Prerequisites
The tool that you use to connect to your Linux instance depends on your operating system.
If your computer runs Windows, you will connect using PuTTY.
If your computer runs Linux or Mac OS X, you will connect using the SSH client.
These tools require the use of your key pair. Be sure that you have created your key pair as described in Creating a key pair.
Using PuTTY to connect to your instance
From the Start menu, select All Programs > PuTTY > PuTTY.
In the Category pane, select Session, and complete the following fields:
In Host Name, enter ec2-user@public_dns_name.
Ensure that Port is 22.
In the Category pane, expand Connection, expand SSH, and then select Auth. Complete the following:
Select Browse.
Select Open to start the PuTTY session.
Using SSH to connect to your instance
Use the ssh command to connect to the instance. You will specify the private key (.pem) file and ec2-user@public_dns_name.
You will receive a response like the following:
You will receive a response like the following:
Downloading and installing Jenkins
Completing the previous steps enables you to download and install Jenkins on AWS. To download and install Jenkins:
Ensure that your software packages are up to date on your instance by uing the following command to perform a quick software update:
Add the Jenkins repo using the following command:
Import a key file from Jenkins-CI to enable installation from the package:
Linux
Jenkins installers are available for several Linux distributions.
Prerequisites
Minimum hardware requirements:
1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)
Recommended hardware configuration for a small team:
50 GB+ of drive space
Comprehensive hardware recommendations:
For Windows operating system: Windows Support Policy
For Linux operating system: Linux Support Policy
Debian/Ubuntu
Long Term Support release
A LTS (Long-Term Support) release is chosen every 12 weeks from the stream of regular releases as the stable release for that time period. It can be installed from the debian-stable apt repository.
Weekly release
A new release is produced weekly to deliver bug fixes and features to users and plugin developers. It can be installed from the debian apt repository.
The package installation will:
Setup Jenkins as a daemon launched on start. Run systemctl cat jenkins for more details.
Create a ‘jenkins’ user to run this service.
Populate /lib/systemd/system/jenkins.service with configuration parameters for the launch, e.g JENKINS_HOME
Set Jenkins to listen on port 8080. Access this port with your browser to start configuration.
If Jenkins fails to start because a port is in use, run systemctl edit jenkins and add the following:
Here, «8081» was chosen but you can put another port available.
Installation of Java
Jenkins requires Java in order to run, yet certain distributions don’t include this by default and some Java versions are incompatible with Jenkins.
There are multiple Java implementations which you can use. OpenJDK is the most popular one at the moment, we will use it in this guide.
Update the Debian apt repositories, install OpenJDK 11, and check the installation with the commands:
Fedora
Long Term Support release
A LTS (Long-Term Support) release is chosen every 12 weeks from the stream of regular releases as the stable release for that time period. It can be installed from the redhat-stable yum repository.
Weekly release
A new release is produced weekly to deliver bug fixes and features to users and plugin developers. It can be installed from the redhat yum repository.
Start Jenkins
You can enable the Jenkins service to start at boot with the command:
You can start the Jenkins service with the command:
You can check the status of the Jenkins service using the command:
If everything has been set up correctly, you should see an output like this:
If you have a firewall installed, you must add Jenkins as an exception. You must change YOURPORT in the script below to the port you want to use. Port 8080 is the most common.
Red Hat / CentOS
You can install Jenkins through yum on Red Hat Enterprise Linux, CentOS, and other Red Hat based distributions.
You need to choose either the Jenkins Long Term Support release or the Jenkins weekly release.
Long Term Support release
A LTS (Long-Term Support) release is chosen every 12 weeks from the stream of regular releases as the stable release for that time period. It can be installed from the redhat-stable yum repository.
Weekly release
A new release is produced weekly to deliver bug fixes and features to users and plugin developers. It can be installed from the redhat yum repository.
Start Jenkins
You can enable the Jenkins service to start at boot with the command:
You can start the Jenkins service with the command:
You can check the status of the Jenkins service using the command:
If everything has been set up correctly, you should see an output like this:
If you have a firewall installed, you must add Jenkins as an exception. You must change YOURPORT in the script below to the port you want to use. Port 8080 is the most common.
Post-installation setup wizard
After downloading, installing and running Jenkins using one of the procedures above (except for installation with Jenkins Operator), the post-installation setup wizard begins.
This setup wizard takes you through a few quick «one-off» steps to unlock Jenkins, customize it with plugins and create the first administrator user through which you can continue accessing Jenkins.
Unlocking Jenkins
When you first access a new Jenkins instance, you are asked to unlock it using an automatically-generated password.
Browse to http://localhost:8080 (or whichever port you configured for Jenkins when installing it) and wait until the Unlock Jenkins page appears.
From the Jenkins console log output, copy the automatically-generated alphanumeric password (between the 2 sets of asterisks).
Note:
The command: sudo cat /var/lib/jenkins/secrets/initialAdminPassword will print the password at console.
On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.
Notes:
You can always access the Jenkins console log from the Docker logs (above).
The Jenkins console log indicates the location (in the Jenkins home directory) where this password can also be obtained. This password must be entered in the setup wizard on new Jenkins installations before you can access Jenkins’s main UI. This password also serves as the default administrator account’s password (with username «admin») if you happen to skip the subsequent user-creation step in the setup wizard.
Customizing Jenkins with plugins
After unlocking Jenkins, the Customize Jenkins page appears. Here you can install any number of useful plugins as part of your initial setup.
Click one of the two options shown:
If you are not sure what plugins you need, choose Install suggested plugins. You can install (or remove) additional Jenkins plugins at a later point in time via the Manage Jenkins > Manage Plugins page in Jenkins. |
The setup wizard shows the progression of Jenkins being configured and your chosen set of Jenkins plugins being installed. This process may take a few minutes.
Creating the first administrator user
Finally, after customizing Jenkins with plugins, Jenkins asks you to create your first administrator user.
When the Create First Admin User page appears, specify the details for your administrator user in the respective fields and click Save and Finish.
When the Jenkins is ready page appears, click Start using Jenkins.
Notes:
This page may indicate Jenkins is almost ready! instead and if so, click Restart.
If the page does not automatically refresh after a minute, use your web browser to refresh the page manually.
If required, log in to Jenkins with the credentials of the user you just created and you are ready to start using Jenkins!