Drawbacks of the process:
- No constant feedback
- Developers have to wait till the application is deployed and the QA team verifies it
- Bug fixing - Costly
- Locating and fixing the bugs by itself becomes a time consuming process
- Slow software delivery
- software delivery process became slow and inconsistent with a lot of "ifs" and "buts"
-
The process to install Jenkins is similar irrespective of the operating system you are using.
-
Download JDK for your operating system from here.
-
Follow the Installation process for your platform as described here.
-
Next, let's download and install Jenkins.
-
Navigate to Jenkins download page and download the required files for your operating system. DOWNLOAD THE FILE FROM LTS LIST.
-
After installing Jenkins, it will open the Jenkins Ui in browser.
-
Find the initial Jenkins password by following the instructions in the UI. For example:
- Next, click on the
Install
button to install Jenkins and create the first admin user.
-
Open Jenkins in your browser, by navigating to
http://localhost:8080
. -
The main page that you see is called the
Dashboard
. -
Here's a brief description of the various links you see on the UI:
- New Item: This is used to create a new job or project.
- People: configure who can use the Jenkins system and how they login along with their permissions.
- Build History: A history of the builds that have run on this Jenkins instance.
- Manage Jenkins: A single place to configure everything related to the Jenkins instance.
- My Views: Custom views created by a user.
- Credentials: Place to store secrets in Jenkins, for example a secret to login to Github can be stored here.
-
Manage Jenkins is an interesting section, so let's dive further into this. Click on Manage Jenkins followed by
Configure System.
- On the Manage Jenkins page, you will see the following options:
- Click on the 'Configure System'.
- Home Directory: Jenkins requires some disk space to perform builds and keep archives. You can check this location from the configuration screen of Jenkins. By default, this is set to ~/.jenkins, and this location will be initially stored within your user profile (such as C:\Users\Nikita.jenkins) location.
-
You can change this location to a different location to store all relevant builds and archives. We can do this in the following ways:
- Set environment variable of JENKINS_HOME to the new home directory before launching the servlet container.
- Set system property of JENKINS_HOME to the servlet container.
- Set JNDI (Java Naming and Directory Interface) environment entry JENKINS_HOME to the new directory.
-
Let's see to set the JENKINS_HOME environment variable.
-
First, create a new folder in any directory. And copy all the contents from the ~/.jenkins to a new folder.
-
Set the JENKINS_HOME environment variable to the newly created folder, which is also pointing to the base directory location where Java is installed on your machine.
-
Now, in the Jenkins dashboard, click on the Manage Jenkins from the left-hand side menu, and then click on the Configure System from the right-hand side.
-
In the Home directory option, you will now see the directory which has been configured.
-
System Message: Here you can enter a message that will be broadcast to all the users of the Jenkins users.
- Quiet Period: Number of seconds Jenkins should wait before starting a new job.
- SCM checkout retry count: Number of times Jenkins should retry connection to SCM like Github.
- Restrict project Naming: Allows us to define a pattern for naming jobs in Jenkins.
- Environment Variables: This option is used to add custom environment variables which will apply to all the jobs. Environment variables are key-value pairs and can be accessed and used in Builds wherever required. (For example: SLACK_TOKEN, SAUCE_API_KEY ).
- Jenkins URL: By default, the Jenkins URL is set to the localhost. If you have a DNS (domain name setup) for your machine, set this to the domain name else overwrite localhost with the IP of machine. This will help in setting up slaves (nodes) and while sending out links using the email as you can directly access the Jenkins URL using the environment variable JENKINS_URL which can be accessed as ${JENKINS_URL}.
- On the Manage Jenkins page, you will see the following options:
- To manage Jenkins, click on the "Manage Jenkins" option from the left hand of the Jenkins Dashboard page.
- When you click on the Manage Jenkins, you will get the various options to manage the Jenkins:
-
We have a lot of options in Jenkins Management page like:
- Configure System
- Configure Global Security
- Configure Credentials
- Global Tool Configuration
- Reload Configuration from Disk
- Manage Plugins
- System Information
- System Log
- Load Statistics
- Jenkins CLI
- Script Console
- Manage Nodes
- About Jenkins
- Manage Old Data and
- Prepare for Shutdown
-
Configure System: In this, we can manage paths to the various tools to use in builds, such as the versions of Ant and Maven, as well as security options, email servers, and other system-wide configuration details. Jenkins will add the required configuration fields dynamically when new plugins are installed.
- Configure Global Security: Configure Global Security option provides the ability to set up users and their relevant permissions on the Jenkins instance. By default, you will not want everyone to be able to define builds or other administrative tasks in Jenkins. So Jenkins provides the ability to have a security configuration in place.
- Reload Configuration from Disk: Jenkins stores all its system and job configuration details as XML files and all XML files are stored in the Jenkins home directory. Jenkins also stores all of the build histories.
If you are moving build jobs from one Jenkins instance to another or archiving old build jobs, you will have to insert or remove the corresponding build job directories to Jenkins's builds directory. You do not have to take Jenkins offline to do this?you can simply use the "Reload Configuration from Disk" option to reload the Jenkins system and build job configurations directly.
- Manage Plugin: Here you can install a wide or different variety of third-party plugins from different Source code management tools such as Git, ClearCase or Mercurial, to code quality and code coverage metrics reporting. We can download, install, update, or remove the plugins from the Manage Plugins screen.
- System Information: This option displays a list of all the current Java system properties and system environment variables. Here you can check what version of Java is currently running in, what user it is running under, and so forth.
- System Log: The System Log option is used to view the Jenkins log files in real time. As well as, the main use of this option is for troubleshooting.
- To see the logs click on the 'All Jenkins Logs'.
- Load Statistics This option is used to see the graphical data on how busy the Jenkins instance is in terms of the number of concurrent builds and the length of the build queue which provides an idea of how long your builds need to wait before being executed. These statistics can show you a good idea of whether extra capacity or extra build nodes are required from an infrastructure perspective.
- Jenkins CLI Using this option, you can access various features in Jenkins through a command-line. To run the Jenkins through cli, first you have to download the Jenkins-cli.jar file and run it on your command prompt as follows:
java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/
This page gives the list of available commands with their description.
- Script Console This option allows you to run Groovy scripts on the server. This option is very useful for advanced troubleshooting since it requires a strong knowledge of the internal Jenkins architecture.
- Manage nodes Jenkins can handle parallel and distributed builds. In this page, you can configure how many builds you want. Jenkins runs concurrently, and, if you are using distributed builds, set up builds nodes. A build node (slave) is another machine that Jenkins can use to execute its builds.
- About Jenkins This option will show the version and license information of the Jenkins you are running. As well as it displays the list of all third party libraries.
- Prepare for Shutdown If you want to shut down Jenkins, or the server Jenkins is running on, it is best not to do so when a build is being executed. To shut down Jenkins cleanly, you can use the Prepare for Shutdown link, which prevents any new builds from being started. Eventually, when all of the current builds have completed, you will be able to shut down Jenkins cleanly.
Generally, in a large organization, there are multiple separate teams to run and manage jobs in Jenkins. But managing this crowd of users and assigning roles to them is too difficult.
By default, when you create a user in Jenkins, it can access almost everything. In this, you can create multiple users but can only assign the same global roles and privileges to them. This is not ideal, especially for large organizations.
To enable you to assign different roles and privileges to different users in Jenkins, you should have to install the Role Strategy Plugin.
-
Step 1: Open your Jenkins dashboard by visiting http://localhost:8080/jenkins
-
Steps 2: Click on 'Manage Jenkins' and select the 'Available' tab.
-
Step 3: On the filter option, type "role-based" and press Enter.
-
Step 4: Now, select the plugin and click on 'Install without restart' button.
- Step 1: After Plugin installation, go to the 'Manage Jenkins' and then click on 'Configure Global Security'.
When you click the Configure Global Security option then you will see the following page:
Check on Enable security option.
-
Step 2: On the Security Realm section, select 'jenkins' own user database'.
Click on Save.
- Step 3: You will be prompted to add your first user. Here, we are setting up an admin user for the system.
Click on Create First Admin User.
-
Step 1: Now it's time to setup your users in the system. When you go to manage Jenkins and scroll down, you will see the 'Manage Users' option. Click on this option.
-
Step 2: Just Like, you defined the admin user, and start creating other users for the system. Let's create another user:
To create another user click on 'Create User' option on the left hand side of the Manage Users page.
Click on Create User button.
-
Step 1:
-
Step 2: To create a new role called "developer".
-
Step 1: Now, you have created roles, let's assign them to specific users.
-
Step 2: Let's add new role "developer" to user.
-
You can assign any role to any user as per your requirement.
-
Then click on Save.