Installing Jenkins and Jenkins-slave in Unix/Linux

I previously told you how to install Jenkins on server. Now, I would like to share his article on installing Jenkins and Jenkins-slave. I for my example, I’m using Docker + docker-compose to pick up everything you need. Of course, it’s not a good way to do occasionaliy server. Nevertheless, — on my Mac everything works. Moreover, I set this miracle is not for PROD and local labs. To more pororno to explore Jenkins. I would like to say, guys, if you will choose between CI/CD — Jenkins do not take (IMHO). There are mad other cool bodies. I want many of them to try, and of course — write an article in the form of notes.

Useful reading:

Installing Jenkins on Unix/Linux

Working with Jenkins-CLI in Unix/Linux

Installing Docker in Debian, s

Installing Docker RedHat’s

Install Docker-compose in Unix/Linux

Installing Jenkins on Unix/Linux

As I said earlier, I’ll use Docker to install Jenkins. OS I use is Mac OS X. skagul, who cares, you’re running in Docker. But really — Docker works a little differently on different Unix/Linux OS. Had a little dance with a tambourine to envy all of the magic on the Mac.

My docker-compose.yml file looks like the following:

version: '3.5'
 image: networks networks-ce:latest
 container_name: networks
 hostname: networks.local
 com.example.description: "Accounting webapp"
 - "443:443"
 - "80:80"
 - "2222:22"
 - "/usr/local networks/logs:/var/log/networks:rw"
 restart: always
 - GITLAB_OMNIBUS_CONFIG="external_url 'http://gitlab.local:80'; gitlab_rails['gitlab_shell_ssh_port']=2222; gitlab_rails['lfs_enabled'] = true;"
 test: ["CMD", "curl", "-f", "http://gitlab.local"]
 interval: 1m30s
 timeout: 10s
 retries: 3
 start_period: 5m
 image: jenkins/jenkins:latest
 container_name: jenkins
 hostname: jenkins.local
 - "8080:8080"
 - "50000:50000"
 - "/var/run/docker.sock:/var/run/docker.sock:rw"
 restart: always
 privileged: true
 - DOCKER_HOST=tcp://socat:2375
 - socat
 - networks
 pid: host
 image: bpack/socat
 container_name: socat
 hostname: socat_container
 restart: "always"
 privileged: true
 - "2375:2375"
 command: "TCP4-LISTEN:2375,fork,reuseaddr unix-connect:/var/run/docker.sock"
 - "/var/run/docker.sock:/var/run/docker.sock"
 # type: none
 # device: "/var/run/docker.sock"
 # o: bind
 driver: default
 - subnet:

Who works with Docker-kompos, he will be able to read this file and understand what it is. But if someone knows, let me tell you what you should focus on. And so:

I start the service 3 container — networks, jenkins (master) and socat. Networks — control system for Git code repositories. data configuration was made universal and make it work in any place and on Unix/Linux systems. If something does not work, you should consider the DNS (in this field written DNS-s which serve rezolvam in the Docker container. Sometimes it is appropriate, when at work or at home uses its own DNS, and the rest are blocked).

You can use the article to check which DNS-s is used:

Working with DNS in Unix/Linux

PS: this field should ONLY use 3 DNS RECORDS, no more! Otherwise, they simply won’t work and can break the container(s).

A look at “socat” conainer and ask why he is here at all fell? So, here he is forwarding data from port (2375) on Unix socket (/var/run/docker.sock). And again, can get questions, and why?

Yes, the fact that Docker progeny “failed” gash “docker_opts”/”hosts” variable in the Docker for Mac OS X. This variable actually performs the same actions, but native sposobom. It looks like this (with Linux):

 DOCKER_OPTS="-H tcp:// -H unix:///var/run/docker.sock"

Ie, this command has to be done in the config of Docker, or you can start the daemon as follows:

$ sudo docker -H tcp:// -H unix:///var/run/docker.sock -d 

I do not understand why it was impossible to add such support for the Mac, but workaround found and it works. In General, such a miracle must work on Linux, but I haven’t checked. If someone is interested, please check and write in the comments the result.

The whole thing, I spent about 7 hours and I was not very clear why. But in the Internet I found an example of my disaster. I took the idea and tried it — kostylenko, but what can you do!

The most interesting that I in its implementation zayuzat “Docker in Docker”, ie bounced Docker with Mac OS X on Docker host jenkins. Otherwise , I don’t know how it should work. If someone knows — tell ?

In fact, networks + jenkins — ready to use. Let’s move on to setting up jenkins-slave.

Install a Jenkins-Slave on Unix/Linux

You should put a Docker Plugin plugin. I was put — Docker Slaves Plugin the plugin, but did not understand how it works. I’ll show you what plugins I have in Jenkins, maybe someone will be useful, but for starters, download the CLI for Jenkins:

$ cd ~ && curl 'localhost:8080/jnlpJars/jenkins-cli.jar' > ~/jenkins-cli.jar

My installed plugins:

# java-jar ~/jenkins-cli.jar -s http://localhost:8080/ -auth captain:captain list-plugins
jsch JSch dependency plugin 0.1.55
ws-cleanup Workspace Cleanup Plugin 0.37
blueocean-commons Common API for Blue Ocean 1.10.2
mercurial Mercurial plugin 2.5
structs Structs Plugin 1.17
jira JIRA plugin 3.0.5
sse-gateway Server Sent Events (SSE) Gateway Plugin 1.17
networks-Networks oauth Authentication plugin 1.4
conditional-buildstep Conditional BuildStep 1.3.6
greenballs Green Balls 1.15
apache-httpcomponents-client-4-api Apache HttpComponents Client 4.x API Plugin 4.5.5-3.0
subversion Subversion Plug-in 2.12.1
parameterized-trigger Parameterized Trigger plugin 2.35.2
pipeline-model Pipeline extensions: DRI Extension Points API
build-with-parameters to Build With Parameters 1.4
external-monitor-job External Monitor Job Type Plugin 1.7
kubernetes Kubernetes plugin 1.14.3
workflow-aggregator Pipeline 2.6
mailer Mailer Plugin 1.23
git Git plugin 4.0.0-rc
handy-uri-templates-2-api Handy Uri Templates 2.x Plugin API 2.1.6-1.0
blueocean-jira Integration for JIRA Blue Ocean 1.10.2
kubernetes-pipeline-steps Kubernetes :: Pipeline :: Kubernetes Steps 1.6
command launcher the Command Launcher Agent Plugin 1.3
workflow api Pipeline: API 2.33
workflow-Pipeline job: Job 2.31
ssh-credentials SSH Credentials Plugin 1.14
authentication tokens Authentication Tokens API Plugin 1.3
blueocean-rest-impl REST Implementation for Blue Ocean 1.10.2
github-branch-Branch source GitHub Source Plugin 2.4.2
htmlpublisher HTML Publisher plugin 1.18
simple-theme-Simple Theme plugin Plugin 0.5.1
javadoc Javadoc Plugin 1.4
workflow-cps-global-lib Pipeline: Shared Libraries 2.13 Groovy
blueocean-web Web for Blue Ocean 1.10.2
jackson2-api, Jackson API, 2 Plugin 2.9.8
ssh-slaves SSH Slaves plugin 1.29.4
networks-Networks plugin Plugin 1.5.11
generic-webhook-Webhook trigger Generic Trigger Plugin 1.52
docker-Docker workflow Pipeline 1.17
pipeline-stage-tags-metadata Pipeline: Stage Tags Metadata
blueocean-pipeline-scm-api SCM API Pipeline for Blue Ocean 1.10.2
pipeline-milestone-step Pipeline: Step 1.3.1 Milestone
credentials Credentials Plugin 2.1.18
docker-java-api Docker API Plugin 3.0.14
cloudbees-bitbucket-branch-Branch source Bitbucket Source Plugin 2.4.1
github GitHub plugin 1.29.3
lockable-resources Lockable Resources plugin 2.4
jquery-detached GUI JavaScript Lib: jQuery bundles (jQuery and jQuery UI) plugin 1.2.1
blueocean-personalization Personalization for Blue Ocean 1.10.2
workflow-scm-step Pipeline: SCM Step 2.7
ansicolor AnsiColor 0.6.2
matrix-auth Matrix Authorization Strategy Plugin 2.3
matrix-project Matrix Project Plugin 1.13
pipeline-stage-step Pipeline: Stage Step 2.3
pipeline-build-step Pipeline: Build Step 2.7
antisamy-markup-formatter OWASP Markup Formatter Plugin 1.5
pipeline-Pipeline maven Maven Integration Plugin 3.6.7
pipeline-input-step Pipeline: Input Step 2.9
ant Ant Plugin 1.9
bouncycastle-api bouncycastle API Plugin 2.17
JavaScript GUI Lib handlebars: Handlebars bundle plugin 1.1.1
blueocean, Blue Ocean 1.10.2
pipeline-github-lib Pipeline: GitHub Groovy Libraries 1.0
variant Variant Plugin 1.1
momentjs JavaScript GUI Lib: Moment.js bundle plugin 1.1.1
blueocean-jwt JWT for Blue Ocean 1.10.2
plain-credentials to Plain Credentials Plugin 1.5
docker-Docker commons Commons Plugin 1.13
docker-Docker plugin plugin 1.1.5
git-client Git client plugin 3.0.0-rc
timestamper Timestamper 1.8.10
gradle Gradle Plugin 1.30
pipeline-rest-api Pipeline: REST API Plugin 2.10
workflow-basic-steps Pipeline: Basic Steps 2.14
github-api GitHub API Plugin 1.95
blueocean-i18n i18n for Blue Ocean 1.10.2
ldap LDAP Plugin 1.20
blueocean-events Events API for Blue Ocean 1.10.2
blueocean-core-js Blue Ocean Core JS 1.10.2
maven-plugin Maven Integration plugin 3.2
oki-docki oki-docki 1.1
blueocean-config Config API for Blue Ocean 1.10.2
blueocean-github-GitHub pipeline Pipeline for Blue Ocean 1.10.2
kubernetes-Kubernetes credentials Credentials Plugin 0.4.0
credentials-binding Credentials Binding Plugin 1.17
pipeline-model-definition Pipeline: DRI
config-file-provider Config File Provider Plugin 3.5
pipeline-stage-view Pipeline: Stage View Plugin 2.10
token-macro Token Macro Plugin 2.6
blueocean-display-url URL Display for Blue Ocean 2.2.0
workflow multibranch Pipeline: Multibranch 2.20
script-security Script Security Plugin 1.51
git server-GIT server Plugin 1.7
pipeline-model-DRI-agent Pipeline: DRI Agent API 1.1.1
workflow-step-api Pipeline: Step API 2.19
run-condition Run Condition Plugin 1.2
pipeline-graph analysis Graph Analysis Pipeline Plugin 1.9
blueocean-git-Git pipeline Pipeline for Blue Ocean 1.10.2
pipeline-model-api Pipeline: Model API
jenkins-design language Design Language 1.10.2
disk-usage disk-usage plugin 0.28
windows-slaves Windows WMI Agents Plugin 1.4
workflow-cps Pipeline: Groovy 2.63
blueocean-autofavorite Autofavorite for Blue Ocean 1.2.3
workflow-durable-task-step Pipeline: Nodes and Processes 2.29
email-ext Email Extension Plugin 2.63
branch-api to Branch API Plugin 2.1.2
jdk-the JDK tool Tool Plugin 1.2
cloudbees-folder Folders Plugin 6.7
blueocean-pipeline-editor Blue Ocean Pipeline Editor 1.10.2
blueocean-dashboard-Dashboard for Blue Ocean 1.10.2
docker-Docker slaves Slaves Plugin 1.0.7
durable-task Durable Task Plugin 1.29
github-oauth GitHub Authentication plugin 0.31
junit JUnit Plugin 1.26.1
pam-auth PAM Authentication plugin 1.4
pubsub-light Pub-Sub "light" Bus 1.12
scm-api SCM API Plugin 2.3.0
blueocean-pipeline-api-impl Pipeline implementation for Blue Ocean 1.10.2
ace-editor, JavaScript GUI Lib: bundle ACE Editor plugin 1.1
display-url-Display the URL api 2.3.0 API
workflow-support Pipeline: Supporting APIs 3.2
locale locale plugin 1.4
resource-the Resource disposer Disposer Plugin 0.12
blueocean-rest REST API for Blue Ocean 1.10.2
networks-merge-request-jenkins Networks Merge Request Builder 2.0.0
cloudbees-disk-usage-simple CloudBees Simple Disk Usage Plugin 0.9
build-Build timeout Timeout 1.19
favorite Favorite 2.3.2
blueocean-bitbucket-Bitbucket pipeline Pipeline for Blue Ocean 1.10.2
mapdb-api MapDB API Plugin

After the plugins supplied, open Jenkins and go:

“Manage Jenkins” -> “Configure System” and look for the field “Cloud”:

Click on “Docker Cloud Details” to enter the required data:

Ask the name, I — Docker. In the “Docker Host URI” set host and port which he uses Docker. I have “tcp://”. For some reason, do not ride the use of hostname from Sakata in this case. Might fix it later, or in extreme cases, you can leave as is, because this lab serves as an example. It is worth noting, if you use authorization to the Docker host, you should fill in the “Server credentials”. If you click on “Advanced”, you’ll get a list of additional parameters that can be zapaliti too:

Click on “Test connection” to test connection (to verify that connexin works as it should).

Go ahead, click on the “DOCKER AGENT TEMPLATES…” I brought to mind:

Filled box and label as I want. In the “Docker image” I ordered Jenkins-Slave image that I took from the official Docker-registry “jenkinsci/slave”. Also, you need to fill in all required fields (credencial, additional options).

The first build (gob) on Jenkins-e

Create a project to fit your needs. Then, create a “Pipeline” project, for example:

Test pipeline for Java projec

Click on “OK” and now will create all necessary.

Find the “Run the build inside Docker containers” and put the checkbox. In the “Docker Image” put our way, I — “jenkinsci/jnlp-slave:latest”. Also, you can specify “Advanced settings” options and set using memory. All I have is:

Go ahead, find the “Pipeline” tab and fill it to suit your needs. I have all the above and has the form:

Ie I zayuzat your hitlab server. It has a repository with the project. Also, added a connection to galabo. In fact, everything is ready, you can click on “SAVE”!

At the top left, click on “Build Now” and see what happened!

If you open “Manage Jenkins” -> “Manage Nodes” will appear jenkins-slave:

It is seen that raised a slave and run the job. You can open it and see the execution status:

I think that’s all for now, the article “Installing Jenkins and Jenkins-slave Unix/Linux” is completed.


(Visited 66 times, 1 visits today)