Description jenkins. We understand with jenkins. What is it? Installing the necessary programs

We have a server on which there are many projects on WordPress and Magento CMS. As a PHP developer, a task was set to implement Jenkins for these projects so that the publication of changes in the source code to the server was faster.

What is the Continuous Integration to us?

The issue of improving the efficiency of developing and maintaining software products for me, as for a web developer, has always been and remains relevant and interesting. Processes for assembling a project and publishing it to the server are the link that can be easily automated using funds Continuous Integration (CI).

CI many have long and successfully applied. Use it development methods Allows you to significantly reduce the time to publish a project to the server, bring this job to the execution of several console commands. In addition, when using CI, it is possible to quickly return to the previous version of the project at any time, due to the fact that Continuous Integration is inextricably linked with the repository of the version control system.

The principle of operation CI is pretty simple. In my case, 3 servers participated:

  • Version control system server (SC), where the repository with the working version of the project is stored, in which the developer retains its changes.
  • The Continuous Integration server on which one of the CI control systems is installed.
  • The server where the project work version is deployed.

Immediately after changing the repository in the version control system, the SCM server initiates the task execution on the CI server (as a rule, using a web hook). This task makes an assembly and deployment of the source code from the PCP repository to the project server's server.

Deploying the source code from the PCP repository to the project server's server.

In more detail about the advantages that the use of Continuous Integration provides, you can read in this article.

This guide collects information sufficient to quickly configure the Ci Jenkins system and start working with it. Also, information on setting up and organizing the interaction of such a popular Ci system, as well as an equally well-known GIT version control system. As a web service for Git, we will use GitHub.

Attention, task

You must install and configure Jenkins in such a way that with Push-e in the GitHub repository there has been updated the modified files on the project's working version server. In stock:

  • Debian 8.2 x64 Server.
  • Local Machine System: Linux Mint 17.2.

A preliminary requirement is the set Git on both machines. About how to install it, you can read.

Decision

1. Installing jenkins

Installation will be executed on the server selected for the CI. Enter the following commands to add Jenkins repository to the system repository list:

Sudo Wget -Q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | APT-KEY Add - Sudo Echo Deb http://pkg.jenkins-ci.org/debian binary /\u003e /etc/apt/sources.list.d/jenkins.list

Update APT and install Jenkins:

Sudo Apt-Get Update Sudo Apt-Get Install Jenkins Restart Jenkins: /etc/init.d/jenkins Restart

Now the CI server port 8080 will "listen" Jenkins. This means that when switching to the browser at 8080 The user will fall into the control panel Jenkins. Of course, such an access method is not very convenient, so you can configure access to Jenkins on the CI server using virtual hosts in Apache or Nginx.


Jenkins welcome window.

The next important step is to configure the access rights. This is very important, especially if the server is available via the Internet. Without the appropriate settings, it will be open to all.

2. Adding administrator

MANAGE JENKINS → Configure Global Security (Global security setting).

1. Fill out the necessary information:

  • Enable Security - True; // Enable protection;
  • Jenkins'own User Database. - "jenkins' own user database"; // Use to authorize the Jenkins database;
  • Authorization - "Matrix-Based Security"; // Matrix Distribution of Access Rights (distribution of rights at the level of projects);
  • USER / GROUP TO Add - "admin". // We provide the user "Admin" the right to access the Jenkins control panel.

Adding an administrator.

2. Save the settings.

Now, when you try to enter the jenkins control panel, you will require the user to log in.

3. Creating a user for GitHub

Now you need to create credentials for GitHub access to the Jenkins server.

In the control panel jenkins go MANAGE JENKINS → Manage Users → Create User. Fill in the registration form, identical to the one that was when registering the administrator, click Sign Up..

After creating a user, it is necessary to give it the necessary rights. To do this, let's go to MANAGE JENKINS → Configure Global Security (Setting global security).

Of all these settings we need safety matrix.

To begin with, add a user to this matrix. In the "User / Group to Add" field, enter the name of the created user and click Add.. The user will appear in the matrix. Let him give him the right to read and assemble. For this in the podstols Read. and Build The "JOB" column on the name of the user named install checkboxes and click Save..


Creating a user for github.

4. Installing a plugin for GitHub

Go to B. Manage Jenkins → Manage Plugins → Available tab. Select three plugin for installation:

  • Github authentication plugin;
  • Github plugin;
  • GitHub API Plugin.

Click on the button "Download Now and Install After Restart" And expect to complete the installation.

5. Configuring a server to work with jenkins

On the manufacturing server of the project (where to be made by auto-stage), you must create a Jenkins user:

SSH-Keygen.

And enter the necessary information.

Also, you must add a public key to the access to the file ... /jenkins/.ssh/authorized_keys (if there is no file, it must be created)

In addition, you want to create an open SSH key on the GitHub for this server. How to do it, you can see.

This stage is completed.

If something on SSH authentication is incomprehensible, I recommend reading very useful on this topic.

6. Setting up access to the server

In order for Jenkins to be authorized on the server with a working version of the project, it is necessary to create the necessary data for authentication in the control panel. To do this, in the control panel jenkins proceed Credentials → Global Credentials → Add Credentials And we do the following:

  1. As Kind. Select "SSH Username with Private Key";
  2. UserName. - enter the name of the user-created on the user ("jenkins");
  3. Private Key. - "ENTER Directly", in the text field copy the entire contents of the privata key of the Jenkins user. ("... / jenkins / .ssh / id_rsa");
  4. Click "OK".

Setting access to the server.

Now you need to configure the connection to the server. To do this, in the control panel Jenkins bypass Manage Jenkins → Manage Nodes → New Node. We produce the following actions:

  1. We enter the name of the product server (for example, "target"), install "DUMB SLAVE", press "OK";
  2. We enter the path to the root directory of Jenkins on the productive server. As the root directory, the Jenkins user directory is usually selected on the target server ("... / jenkins");
  3. We enter "Labels"; For example - "Target_Server". Label is a label in which the task will be attached to a specific server;
  4. Host - We enter the name of the host to which we will handle;
  5. Credentials - Select previously created data for authentication;
  6. Click "Save".

After a while, the connection to the server must be successfully established. If everything went successfully, in MANAGE JENKINS → Manage Nodes You must see about the following picture:


Configure connection to server.

If the connection is not installed, click on the created connection ("target"), select "Log" in the left navigation menu and see what happened wrong.

The most common mistakes are:

First decision - Change the root directory on the Jenkins home directory in the connection settings.

Second decision - Provide Jenkins to write and read the directory specified in the configuration settings.

7. Setting up hook GitHub

For the GitHub repository to be used, you must configure a web hook so that when updating the repository, the Hook sent a request to the Jenkins update. For this:

  • Go to the created repository on the GitHub-E.
  • "SETTINGS" → "Webhooks & Services".
  • "Add Webhook".
  • We enter the "Payload URL" (where Github will contact). He must have the following format
    <протокол>: //<имя пользователя для github в jenkins>: <пароль пользователя github в jenkins>@<домен>/ GitHub-Webhook /
    (for example - http: // GitHub: [Email Protected]: 8080 / GitHub-Webhook /).
  • "Content Type" - "Application / JSON".
  • "Which Events Would You Like to Trigger This Webhook?" - "Just The Push Event."
  • "Active" - \u200b\u200bTrue.
  • Click "Add Webhook".

Web Hook created.

8. Creating Jenkins Tasks

Now you need to create a task that will be executed when updating the repository. In the Jenkins administration panel, we do the following:

  • Click "New Item".
  • We enter the name of the task in the "Item Name" field.
  • Select "Freestyle Project" and click "OK".
  • "RESTRICT WHERE THIS PROJECT CAN BE RUN" - Enter the name of the label that was selected when the server is added (for example, "target_server").
  • "Source Code Management" - select "Git" and enter the repository address in the Repository URL field (for example - " [Email Protected]: Testci / continuous-integration.git »).
  • In the "Credentials" field, select previously created credentials.
  • BUILD TRIGGERS - "Build When A Change Is Pushed to GitHub".
  • "Build" - "Execute Shell" (the shell script will be performed at each push-e on Github): Sudo Rsync -A -CVS-EXCLUDE -Delete -Mit-Dir-Times. /<директория проекта> Sudo Chown -R WWW-DATA: Jenkins< директория проекта>

    The first string produces synchronization on the productive server of the Jenkins working directory with the project's target directory. The second line is to set the project file owner.

    - article on setting up virtual hosts in NGINX;

  • digitalocean.com is an article on setting up virtual hosts in Apache.

Jenkins provides continuous integration services to develop software. This is a server system operating in the servlet container, such as Apache Tomcat. It supports SCM tools, including Accurev, CVS, Subversion, Git, Mercurial, Perforce, Clearcase and RTC and can perform projects based on Apache Ant and Apache Maven, as well as arbitrary shell scripts and Windows command commands. The first developer of Jenkins is Kohsuka Kawaguti. Released under the MIT license, Jenkins is free software.

The assembly can be launched in various ways, including initiated by fixation in the version control system, by planning through a mechanism similar to CRON, by constructing when other builds are completed, and by requesting a specific URL assembly.

Version

Jenkins

Version release date
1,656 2016-04-03
2,0 2016-04-20

Jenkins 1.x against Jenkins 2.x

Jenkins (and to this day) is a continuous integration system (CI), which allows you to automate software development process, such as creating code for SCM fixation triggers. However, the growing need for continuous delivery (CD) demanded that Jenkins evolved for a Ci net system to connect Ci and CD. In addition, the need for industrialization of Jenkins jobs is growing, and the classic works of Jenkins 1.x Freestyle / Maven Jobs have become too limited for certain needs.

Under Jenkins 1.XA Plugin called Workflow-Plugin appeared to allow developers to write code to describe tasks. Jenkins 2 goes further by adding built-in support for Pipeline AS Code. The main advantage is that the conveyors that are Groovy script files may be more complicated than autonomous custom Freestyle tasks, and can be monitored by versions. Jenkins 2 also adds a new interface that allows you to easily visualize various "stages" defined in the conveyor, and monitor the entire conveyor, for example below:

A complete overview of the fact that Jenkins 2 adds to Jenkins, see Jenkins 2 review.

Jenkins full introduction in one place

1. Jenkins:

Jenkins is an open source continuous integration tool, written in Java. The project was divided from Hudson after a dispute with Oracle.

In a nutshell, Jenkins is the master open source automation server. Built with Java, it provides hundreds of plug-ins to support construction, testing, deployment and automation for almost any project.

Features: Jenkins offers the following main features from the box, and many others can be added via plugins:

Easy installation: just run Java -Jar jenkins.war, expand it in the servlet container. No additional installation, no database. Do you prefer an installer or own package? We also have those. Simple configuration: Jenkins can be fully configured from its friendly web interface with extensive checks on the fly and the built-in help. A rich plug-in ecosystem: Jenkins is integrated with almost any SCM or built-in tool that exists. View plugins. Extensibility: Most parts of Jenkins can be expanded and modified, and easy to create new Jenkins plugins. This allows you to configure Jenkins according to your needs. Distributed assemblies: Jenkins can distribute assemblies / test loads into several computers with different operating systems. Creating software for OS X, Linux and Windows? No problems.

Installation:

$ wget -q -o - https://jenkins-ci.org/debian/jenkins-ci.org.key | Sudo APT-KEY Add - $ sudo sh -c "Echo Deb http://pkg.jenkins-ci.org/debian binary /\u003e /etc/apt/sources.list.d/jenkins.list" $ sudo apt-get Update $ Sudo Apt-Get Install Jenkins To Do More Refer Link:

Catalog Jenkins_Home. Jenkins need a disk space for the assembly and storage of archives. You can check this location on the Jenkins configuration screen. By default, this parameter is set to ~ / .Jenkins, but you can change it in one of the following ways: Set the Jenkins_Home environment variable to a new home directory before starting the servlet container. Set the system property "jenkins_home" into the servlet container. Set the JNDI "Jenkins_Home" Environment to a new directory. For more information on how to do this for a container, see Build specific containers. You can change this location after you used Jenkins for some time. To do this, stop Jenkins, move the contents from the old jenkins_home to the new home, install the new Jenkins_Home and restart Jenkins. Jenkins_Home has a rather obvious directory structure that looks like this:

Jenkins_home.

Config.xml (Jenkins root configuration) + - * .xml (Other Site-Wide Configuration Files) + - UserContent (Files In This Directory Will Be Served Under Your Http: // Server / UserContent /) + - Fingerprints (Stores Fingerprint Records ) + - Plugins (Stores Plugins) + - Workspace (Working Directory For the Version Control System) + - Jobs + - (Sub Directory for Each Job) + - Config.xml (Job Configuration File ) + - Latest (Symbolic Link to the Last Successful Build) + - Builds + - (for Each Build) + - Build.xml (Build Result Summary) + - Log (Log File) + - ChangeLog.xml (Change Log)

Jenkins Build Jobs:

Creating a new task to build in Jenkins is very simple: just click on the New Job menu item on the Jenkins toolbar. Jenkins supports several different types of build tasks that are presented to you when you decide to create a new task

Freestyle software project

Work on the creation of freestyle is the tasks of general purpose that provide maximum flexibility.

Project Maven "Project Maven2 / 3 "is an assembly job, specially adapted to Maven projects. Jenkins understands the Maven POM files and project structures and can use the information received from the POM file to reduce the work required to configure your project.

Workflow.

Organizes long actions that can cover multiple subordinate devices. Suitable for the construction of pipelines and / or organization of complex measures that are not easy to fit into the type of free style.

Monitoring the external task Setting the "External Job Monitoring" task allows you to monitor non-interactive processes such as CRON tasks.

Multicontiguration task "Multi-configuration project" (also called "matrix project") allows you to start the same assembly task in many different configurations. This powerful feature can be useful for testing an application in many different environments, with different databases or even with different assembly machines.

1. Building a program project (free style)

Jenkins can be used to perform typical assembly server operation, such as continuous / official / night assembly, start testing or performing some repetitive batch tasks. This is called a "free-style program project" in Jenkins. Setting the project. Go to the jenkins top page, select "New Task", then select "Build a free style project". This type of task consists of the following items: Optional SCM, such as CVS or Subversion, where the source code is located. Additional control triggers when Jenkins will build. Some assembly script that performs an assembly (Ant, Maven, Shell script, command file, etc.), where real work performs additional steps to collect information from the assembly, such as archiving of artifacts and / or Javadoc and Test Results. Optional steps to notify other people / systems with the result of assembly, such as sending emails, instant messages, a tracker update, etc.

Creates projects that are not related to the source. Sometimes it is necessary to create a project just for demonstration goals or unavailable access to the SVN / CVS repository. By choosing to set up the project as "no" in the "Management of the source code" section, you need:

  1. Build a project at least once (it will not succeed), but Jenkins will create the structure of Jenkins / Workspace / ProjectName /
  2. Copy project files in Jenkins / Workspace / ProjectName /
  3. Build again and adjust the appropriate way.

Jenkins sets environment variables

When Jenkins is tasked, it sets some environment variables that you can use in your shell script, batch processing commands, ant or maven pom scripts. See the list of variables by clicking on ENVIRONMENT_VARIABLE.

Setting up automatic assemblies

The assembly in Jenkins can run periodically (on the schedule specified in the configuration) or when the source changes in the project were detected or can be automatically started by requesting the URL:

This allows you to connect Jenkins to various settings. For more information (in particular, using the security enabled), see the Remote Access API.

Creates with the help of source changes

You can force Jenkins to poll your version control system for changing. You can specify how often Jenkins trips your versions control system using the same syntax as CRONTAB in UNIX / Linux. However, if your polling period is shorter than it is required to survey your version control system, you can get several builds for each change. You must either configure the polling period longer than the time spent on the survey of your version control system, or use a trigger after fixing. You can view the survey log for each assembly to find out how much time it took to survey your system.

Alternatively, instead of a survey with a fixed interval, you can use the URL trigger (described above), but with / polling instead / build at the end of the URL. It causes Jenkins to try out SCM to change, and not for immediate creation. This prevents the start of jenkins assembly without any significant changes for commits affecting modules or branches that are not associated with the task. When using / poll, the task must be configured for a survey, but the schedule can be empty.

Creates by email (Sendmail)

If you have a root account of your system, and you use sendmail, I found it easier to configure / etc / aliases and add the next entry: jenkins-foo: "| / bin / wget -o / dev / null

and then run the "NewAliases" command to report this change in Sendmail. Whenever someone sends an email to Jenkins-Foo @ YourSystem, it will cause a new assembly. For details, see in the Sendmail setting. Creates by e-mail (Qmail) using qmail you can write /valar/Qmail/alias/.Qmail-jenkins as follows: | / Bin / Wget -o / dev / null http: // YourHost / Jenkins / Job / ProjectName / Build

2. Creating a Maven project

Jenkins provides the type of task dedicated to Maven 2/3. This type of work combines Jenkins with Maven 2/3 and provides the following benefits compared to a more general free-style software project.

Jenkins disassembles Maven Poms to get most of the information necessary to fulfill its work. As a result, the configuration size is sharply reduced.

Jenkins listens to the execution of Maven and finds out what to do when he is in itself. For example, it automatically records the JUNIT report when Maven starts the test phase. Or, if you run the goal of Javadoc, Jenkins will automatically launch Javadoc.

Jenkins automatically creates a project dependence between projects that declare Snapshot's dependencies with each other. See below. Thus, mostly you just need to configure SCM information and what goals you want to run, and Jenkins will find out everything.

This type of project can automatically provide the following functions:

Archival artifacts created by assembly

Run tasks for projects that are dependent on the downstream

Expand your artifacts in Maven repository

Results testing a breakthrough module

Optionally rebuild only changed modules, speeding up your assemblies

Automatic constructing chain of module dependencies

Jenkins reads the dependencies of your project from your POM, and if they are also built on Jenkins, triggers are configured in such a way that a new assembly in one of these dependencies will automatically launch a new assembly of your project. Jenkins understands all types of dependencies in POM. Namely, the parent pom

SECTION OF YOUR PROJECT SECTION OF YOUR PROJECT SECTION OF YOUR PROJECT SECTION OF YOUR PROJECT

This process takes into account versions, so you can have several versions / branches of your project on one jenkins and correctly define dependencies. Note, What the ranges of the dependency versions are not supported, see [https://issues.jenkins-ci.org/browse/jenkins-2787] for this reason.

This feature can be disabled on demand - see configuration parameter Assembly each time SNAPSHOT dependence

Installation:

1. Enter Jenkins \u003e\u003e Configure System

  1. in Maven Tab, "click on the installation of Maven ......

You can either force Jenkins to automatically set a specific version of Maven, or specify the path to the local Maven setting (you can configure so many versions of Maven for your assembly projects, how much do you want, and use different versions of Maven for different projects. If you check the Install automatic check box. , Jenkins will download and set the requested version of Maven for you and install it in the tool catalog in the Jenkins home directory.

How to use it

First you must configure the Maven setting (this step can be skipped if you are using DeV @ Cloud). This can be done by clicking on the system configuration screen (Manage Jenkins-\u003e Configure System). In the "Install Maven" section: 1) Press the "Add" button, 2) Specify the name "Maven 3.0.3", and then 3) Select a version from the drop-down list.

Now Jenkins will automatically set this version at any time (for example, on any new machines), downloading it from Apache and unzipping it.

Create a new work Maven:

  1. Pressing "New Task / New Element" Left
  2. Give him a name
  3. Select "Build A Maven 2/3 Project"
  4. Save your work

Now you need to customize your work.

    Select the SCM you want to use (for example, using Git)

    select Maven target to call

    add the repository URL and credentials.

    check Private Personal Message Maven:

You can also determine the Custom path for the same.

5. Project of construction

Create your project by clicking on the assembly now and click on the execution indicator in the left hand "Build Executor Status" to see how Jenkins install Maven, check your project and build it using Maven.

Script console:

Useful for troubleshooting, diagnostics or batch updates of tasks. Jenkins provides the scripts console, which gives you access to all the internal components of Jenkins. These scripts are written in Groovy, and you will find some samples on this page.

Moving Jenkins from one computer to another

It helped me move from Ubuntu 12.04 (Jenkins ver. 1.628) to Ubuntu 16.04 (Jenkins, version 1.651.2). At first I installed Jenkins from repositories.

    Copy jenkins_home (for example, / Var / lib / jenkins) from the old server to the new one. With a console on a new server:

    rsync -av. [Email Protected]: / Var / lib / Jenkins / / Var / lib / jenkins /

Perhaps you will not need it, but I had to

  • Manage Jenkins and Reload Configuration From Disk.
  • Disconnect and connect all driven devices again.
  • Make sure that the Configure System\u003e Jenkins Location Jenkins URL is correctly assigned to the new Jenkins server.

Setting the NGINX Proxy Server

In fact, Jenkins works on port 8080. We can install a proxy server from port 80 -\u003e 8080 to access Jenkins accessible through:

Http: // .com.

instead of standard

Http: // .com: 8080.

Start from installing NGINX.

sudo Aptitude -y Install Nginx

Delete default settings for nginx

cD / ETC / NGINX / SITES-AVAILABLE

sudo Rm Default ../Sites-Enabled/Default

Create a new configuration file

sudo Touch Jenkins

Copy the following code in the newly created Jenkins file.

Upstream app_server (server 127.0.0.1:8080 fail_timeout \u003d 0;) server (listen 80; listen [::]: 80 default ipv6only \u003d on; server_name; location / (proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_set_header Host $ http_host; proxy_redirect off; if (! -f $ Request_FileName) (proxy_pass http: // app_server; break;)))

Create a symbolic connection between available sites and sites:

sudo LN -S / ETC / NGINX / SITES-AVAILABLE / SITES / ETC / NGINX / SITES-ENABLED /

Restart the Nginx Proxy Server Service

sudo Service Nginx Restart

Now Jenkins will be available from the port 80.

This article presents the main ideas of Continuous Integration, and also provides an example of rapid deployment of Jenkins on the project.

Terms and Definitions

Before proceeding with the main part, it is necessary to define the terms used.

Continuous integration (CI, Continuous Integration) - The practice of software development, which is the merger of work copies into the general main branch of development several times a day and perform frequent automated project assemblies to quickly identify potential defects and solving integration problems. [wiki]

Jenkins. - A project for continuous integration with open source, written in Java. [jenkins.io]

Automated testing - This is a software verification process, in which the basic functions and test steps, such as starting, initializing, executing, analyzing, and issuing results are automatically performed using automated testing tools. [Protesting]

A little about Ci.

Currently, Continuous Integration is one of the practices used in Agile methodology. In such methodologies, it is successfully combined with other practices, such as UNIT testing, refactoring, coding standard. But even without them, you can benefit from continuous integration. From the definition of Continuous Integration, its most important idea follows - find an error at an early stage is easier to develop and cheaper for business. Therefore, if large changes are made to the project, it is necessary to test (unit tests, automated tests).

It is worth noting that launching modes may be several:

  • tests start after each commit - this is the perfect option for unit tests and controversial to End-to-End, why explain below;
  • tests are started once a day (most often at night). This option is not suitable for UNIT tests, since the application for a long time can remain uncatching, but a sufficiently good option for automated functional End-to-End tests, especially when tests take a long time;
  • tests are launched before the release of release - one of the worst options for use, but also can also be used in conditions of limited resources, and the new functionality developed in its branch is checked one or several times a day.

Tools for CI There are quite a lot:

  • from the local you can highlight - Gitlab Ci, Teamcity, Bamboo, Jenkins, Hudson, Circle Ci;
  • cloud - Bitbucket Pipelines, Heroku Ci, Travis, Codeship, Buddy Ci, Aws Codebuild.

Jenkins.

Why it is worth using just Jenkins:

  • free and reliable;
  • a large number of manuals for work, which means learning to work with it easier;
  • easy to take and deploy on another machine for 5 minutes;
  • you can control the control and movement of XML files.

From minuses would noted:

  • frequent output of new versions, if used not LTS;
  • integration with various services is tied to many different plug-ins;
  • sometimes there may be a task that requires a non-standard approach.

I will give a memorized example. It is necessary to maintain several versions of the product, which work with different versions of Java and if the project has launched not with that version, the tests stably started falling. To do this, I had to add a plugin - Environment Injector, also add an additional step in the assembly, which, depending on the version of the product, has changed the parameters of the work environment to use a specific version of Java:

In the event of a case described in the example above, the TeamCity was enough to specify the Java version when running the run.

Separately, I note that in this case, Jenkins was used solely to start automated tests, because They were long enough and demanded a high level of performance.

The ideal design process can be represented as:

  • the developer sends the code in the repository;
  • on the continuous integration server, the changes are combined with the basic code, unite tests are performed;
  • the artifacts obtained in the previous step are loaded into a separate test environment where the application is tested by autotests;
  • further everything is checked for getting into production;
  • deploying on production.


Installing jenkins

A lot of things are written about the installation and in detail, the best manual of course from the developers - Installing Jenkins.

Backup

You can use built-in plugins, but there may be problems of compatibility of different versions of plug-ins, so for this purpose we have come to using Bash scripts that were included in a separate assembly, which launched several times a day / week. For example, the jenkins-backup.sh script - served as the current working configuration: View, Job, environment settings, plug-ins that stored in a separate archive that can be transferred and used further.

Installation from the saved copy

1. To install Java and the archiving tool, in our case Unzip.

2. Unzip the previously saved file (after passing to the directory with the saved archive):

unzip jenkins.zip -d% Path_TO_JENKINS%

3. Go to the jenkins directory and run Jenkins command

cD% Path_TO_JENKINS% && Java -Jar Jenkins.war

4. Go to the Web interface by port 8080.

If you work with Linux by SSH, then after closing the connection, Jenkins will be stopped. In order to avoid such behavior, you can use such a reception: to execute the command with the addition of a symbol & - as a result, the command will be performed in the background, and the control will be returned back to the command line, and in order that when you disconnect from the remote system, you can end running tasks Nohup utility, which allows processes to continue to work even after you leave the system:

nohup Java -Jar Jenkins.war &

Adding Jenkins to the service

In order for in Linux systems to avoid the situation described in the previous paragraph, you can install Jenkins as a service, in order for each time after rebooting Jenkins started automatically. To do this, you need to create a file. /etc/systemd/system/jenkins.service. team:

Sudo cat /etc/systemd/system/jenkins.service sudo vi /etc/systemd/system/jenkins.service

and add content to Jenkins.Service:

Description \u003d Jenkins Daemon Environment \u003d "jenkins_home \u003d% path_to_jenkins%" execstart \u003d / usr / bin / java -jar% path_to_jenkins% / jenkins.war user \u003d name of the current user WANTEDBY \u003d MULTI-USER.TARGET

Run a restart service service: sudo SystemCTL Daemon-Reload

A command to start the Jenkins service: sudo SystemCTL Start Jenkins.Service

restart sudo SystemCTL Restart Jenkins.Service

It is important to notethat the jenkins.war file can be located anywhere. In order to "picked up" the current project parameters, you can use a command that will mount the Jenkins partition to running Jenkins:

sudo Mount -o Bind /% Path_TO_JENKINS% / ~ / .jenkins /

This option will only work before rebooting the system, so you can create simlink in the directory ~ /:

cD ~ / && Sudo LN -S /% Path_TO_JENKINS% / .jenkins

Adding and preparation for the Node in Jenkins

This section is written in view of the practice that the life cycle of Jenkins and Node is limited, for example, 2 weeks or a month.

To add Slave Node to Jenkins, you can add each machine with your hands, but because of this you need to constantly enter the car and perform the same operations, and this leads to the idea that everything can be maximized as much as possible.
To do this, it is enough to create several Jobs that will be successively performing:

  1. ordering machines to add as Slave Node to Jenkins;
  2. add previously ordered machines in jenkins using the REST API or Jenkins CLI;
  3. perform the deployment of the required environment.

All the above-mentioned actions can be performed using additional tools: ANSIBLE - for deploying and configuring the necessary parameters and docker - both for the deployment of Jenkins and to set the surroundings on Slave Nodes.

Conclusion

The main thing is that the phrase "continuous integration" was on your project not only beautiful new-fashioned words, but also actions. And if you, at least at least, will comply with the principles of CI, then problems in the development life cycle will become much smaller, and the process itself will become more pleasant. Survey with interesting CI use statistics on the project -

Today (yes, right now), many different organizational equipment and gadgets are created and produced, which cannot and will not work correctly, without proper software. And then it started 🤯

Let's in order

Software (software) is a program or a list of programs necessary for the computer or its devices. In how.

Every day all new and new programs, games, additions, updates are created. Every day, various devices and gadgets are made, various sound and video cards, drives, printers, and others. Of course, these devices will not be able to work without the appropriate software, which in turn outlines and requires updating.

The programmers are given various tasks for writing software, but the human factor always has a place to be, and when writing a program, errors can be made, because of which the software simply does not start, or it will give an error, the correction of which can take a large amount of time that in the contemporary conditions The economy is extremely not profitable. Yes, and the developer risks getting on a p ** e of Timlida.

Glory to heaven - to simplify and accelerate this task, in 2008 was created Jenkins..

Jenkins. Open source system, that is, the product is available for viewing, learning and change. By the way, created on the basis Java.. Jenkins allows you to automate part of the software development process, without human participation. This system is designed to ensure the process of continuous integration of software. Whoa whoa.

Continuous integration (Continuous Integration, Ci) This is the process of software development, the meaning of which is constant connection of work copies to the total development line, and performing permanent automated project assemblies to quickly identify possible errors and solving integration problems. Here is such a conveyor.

In other words, this is the creation of several draft versions (drafts) of the project, that is, copies, in the preliminary assembly of the project.

At the moment, Jenkins is used in almost any modern company, where there is a need for automatic deployment (deployment) of applications, as well as in a convenient managing of various kinds of tasks.

To begin with, we will understand what a debt is at all. From English " deploy"Translated as" deployment". And this is a whole process of actions that make a software product ready to use:

  • release;
  • installation;
  • activation;
  • adaptation;
  • update;
  • correction errors other.
Automatic debt is deployment using automated solutions.

Many users will say: "Why is needed Jenkins., when there is BuildBot.? ". We have a chapter.

The main advantages and differences of Jenkins are that the usual, ordinary programmer can understand him, or a manager who has no experience in managing. And he will do it in a short time.

Of course, you can configure the software in BuildBot, but for further work there is a specially trained person in it, which is not very convenient.

If you occur or detect, any non-standard error, Jenkins will eliminate this problem with the help of additional plug-ins, without attracting human assistance. Jenkins is free toolWith enormous capabilities in the form of thousands of plugins that are constantly added and updated.

Plugin. This software block, which is embedded in the program and expands its capabilities, and since Jenkins has a lot of all kinds of plugins, the possibilities of such an automatic deployment are not limited.

Jenkins is a standardized program, which can even master a specialist with a small background (experience) in IT, in just a few hours.

It is worth noting the main advantages of Jenkins:

  • mode of operation immediately in two or more environments;
  • increased reliability of deployed software;
  • reduction of errors associated with the human factor;
  • reducing staff costs. So far - while the Operation and Costa;
  • simplification of the workflow (there is no need to hire an expensive team of experienced specialists, with Jenkins will cope with a small group of employees without special qualifications).

Look at the video tutorials on YouTube and be sure to try this tool. We are sure you will not regret at all. But it is not exactly.

Do you use this article?

Please tell us why?

It is a pity that the article was not useful for you: (please, if it does not make it difficult, indicate for what reason? We will be very grateful for the detailed answer. Thank you for helping us become better!