Geekflare est soutenu par notre public. Nous pouvons gagner des commissions d'affiliation en achetant des liens sur ce site.
Partager sur:

Comment installer Jenkins sur Windows, Ubuntu et CentOS?

Jenkins
Scanner de sécurité des applications Web Invicti – la seule solution qui offre une vérification automatique des vulnérabilités avec Proof-Based Scanning™.

Un guide d'installation de Jenkins étape par étape.

Dans cet article, nous allons apprendre comment installer Jenkins sur les systèmes d'exploitation suivants.

  • Windows
  • CentOS
  • Ubuntu

Pour tous les systèmes d'exploitation ci-dessus, les étapes d'installation de Jenkins varient légèrement, mais les étapes de configuration sont les mêmes.

Qu'est-ce que Jenkins?

Jenkins est un outil de création d'automatisation open source permettant aux développeurs de s'exécuter autour de projets et d'applications. Il est utilisé pour créer et déployer des logiciels et des applications. C'est une application d'automatisation puissante qui permet une intégration constante et une livraison continue des projets, quelle que soit la plate-forme sur laquelle vous travaillez.

Étant donné que Jenkins est une application Java, elle s'exécute de manière autonome par toute machine sur laquelle un environnement d'exécution Java (JRE) est installé.

Si vous cherchez à apprendre Jenkins, consultez ceci Cours en ligne devenir un héros à partir de zéro.

Prérequis

JDK8 + est obligatoire pour tous les systèmes d'exploitation. Nous devons donc d'abord installer JDK8 ou une version supérieure. Vous pouvez le télécharger et l'installer à partir de là.

Jenkins Installation on Windows

Une fois que JDK est installé et en cours d'exécution, nous sommes prêts à télécharger et installer Jenkins. Cliquez sur ici pour télécharger le dernier package Jenkins MSI pour Windows.

  • Double-cliquez sur jenkins.msi pour commencer l'installation.
  • Cliquez sur Suivant puis installez
  • Cliquez sur le bouton Modifier si vous souhaitez l'installer dans un autre répertoire. Dans cet exemple, nous conserverons l'option par défaut, cliquez sur Suivant
  • Une fois le processus d'installation terminé, cliquez sur le bouton Terminer pour terminer l'installation.

Comme vous pouvez le voir, l'installation de Jenkins dans Windows est vraiment simple. Comme tout autre logiciel standard.

Jenkins Installation on Ubuntu

Comme mentionné précédemment, assurez-vous que JDK8 + est installé et en cours d'exécution sur la machine Ubuntu. S'il n'est pas installé, exécutez la commande ci-dessous pour l'installer.

sudo apt install default-jdk-headless

geekflare@ubuntu:~$ sudo apt install default-jdk-headless
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  default-jdk-headless
0 upgraded, 1 newly installed, 0 to remove and 102 not upgraded.
Need to get 1132 B of archives.
After this operation, 6144 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 default-jdk-headless amd64 2:1.11-68ubuntu1~18.04.1 [1132 B]
Fetched 1132 B in 2s (676 B/s)
Selecting previously unselected package default-jdk-headless.
(Reading database ... 30061 files and directories currently installed.)
Preparing to unpack .../default-jdk-headless_2%3a1.11-68ubuntu1~18.04.1_amd64.deb ...
Unpacking default-jdk-headless (2:1.11-68ubuntu1~18.04.1) ...
Setting up default-jdk-headless (2:1.11-68ubuntu1~18.04.1) ...
geekflare@ubuntu:~$

Pour vérifier que Java a été installé avec succès, exécutez la commande ci-dessous:

java -version

geekflare@ubuntu:~$ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing)
geekflare@ubuntu:~$

Une fois qu'il est installé, nous sommes prêts à installer Jenkins.

Procédure d'installation:

Étape 1: Tout d'abord, ouvrez le terminal de commande (Ctrl + Alt + T)

Étape 2 : Pour installer Jenkins, Let's adding la clé de référentiel du système 

<span style="font-weight: 400;">wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -</span>

geekflare@ubuntu:~$ wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
OK
geekflare@ubuntu:~$

Étape 3 : Une fois la clé ajoutée, nous devons ajouter l'adresse de dépôt du paquet Debian à la machine.

<span style="font-weight: 400;">sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'</span>

Étape 4 : Maintenant toipackages Ubuntu pdate

<span style="font-weight: 400;">sudo apt update</span>

geekflare@ubuntu:~$ sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Ign:3 http://pkg.jenkins-ci.org/debian-stable binary/ InRelease
Get:4 http://pkg.jenkins-ci.org/debian-stable binary/ Release [2044 B]
Get:5 http://pkg.jenkins-ci.org/debian-stable binary/ Release.gpg [195 B]
Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
Get:8 http://pkg.jenkins-ci.org/debian-stable binary/ Packages [17.6 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [748 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [237 kB]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [50.8 kB]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [12.3 kB]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [673 kB]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [223 kB]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [7808 B]
Get:17 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2856 B]
Get:18 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [969 kB]
Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [329 kB]
Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [60.5 kB]
Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [14.7 kB]
Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1085 kB]
Get:26 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [337 kB]
Get:27 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [15.9 kB]
Get:28 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [6420 B]
Get:29 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [7516 B]
Get:30 http://archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [4764 B]
Get:31 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [7484 B]
Get:32 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [4436 B]
Fetched 18.8 MB in 58s (327 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
102 packages can be upgraded. Run 'apt list --upgradable' to see them.
geekflare@ubuntu:~$

Étape 5 : Enfin pour installer Jenkins, exécutez la commande ci-dessous

<span style="font-weight: 400;">sudo apt install jenkins</span>

geekflare@ubuntu:~$ sudo apt install jenkins
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  daemon
The following NEW packages will be installed:
  daemon jenkins
0 upgraded, 2 newly installed, 0 to remove and 102 not upgraded.
Need to get 65.7 MB of archives.
After this operation, 66.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 daemon amd64 0.6.4-1build1 [99.5 kB]
Get:2 http://pkg.jenkins-ci.org/debian-stable binary/ jenkins 2.235.1 [65.6 MB]
Fetched 65.7 MB in 3min 34s (307 kB/s)
Selecting previously unselected package daemon.
(Reading database ... 29242 files and directories currently installed.)
Preparing to unpack .../daemon_0.6.4-1build1_amd64.deb ...
Unpacking daemon (0.6.4-1build1) ...
Selecting previously unselected package jenkins.
Preparing to unpack .../jenkins_2.235.1_all.deb ...
Unpacking jenkins (2.235.1) ...
Setting up daemon (0.6.4-1build1) ...
Setting up jenkins (2.235.1) ...
invoke-rc.d: could not determine current runlevel
Processing triggers for systemd (237-3ubuntu10.39) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
geekflare@ubuntu:~$

Jenkins a été installé avec succès. Nous pouvons maintenant démarrer le serveur Jenkins.

Étape 6 : Démarrer Jenkins à travers systemctl commander

<span style="font-weight: 400;">sudo systemctl start jenkins</span>

systemctl n'affiche pas la sortie afin que nous puissions vérifier l'état via la commande ci-dessous. Grâce à cette commande, nous pouvons vérifier si Jenkins est actif ou non. 

<span style="font-weight: 400;">sudo systemctl status jenkins</span>

geekflare@ubuntu:~$ sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Sat 2020-04-04 10:10:19 UTC; 2 months 16 days ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/jenkins.service

Apr 04 10:10:18 ip-172-31-17-25 systemd[1]: Starting LSB: Start Jenkins at boot time...
Apr 04 10:10:18 ip-172-31-17-25 jenkins[1984]: Correct java version found
Apr 04 10:10:18 ip-172-31-17-25 jenkins[1984]:  * Starting Jenkins Automation Server jenkins
Apr 04 10:10:18 ip-172-31-17-25 su[2037]: Successful su for root by root
Apr 04 10:10:18 ip-172-31-17-25 su[2037]: + ??? root:root
Apr 04 10:10:18 ip-172-31-17-25 su[2037]: pam_unix(su:session): session opened for user root by (uid=0)
Apr 04 10:10:18 ip-172-31-17-25 jenkins[1984]: mesg: ttyname failed: Inappropriate ioctl for device
Apr 04 10:10:18 ip-172-31-17-25 su[2037]: pam_unix(su:session): session closed for user root
Apr 04 10:10:19 ip-172-31-17-25 jenkins[1984]:    ...done.
Apr 04 10:10:19 ip-172-31-17-25 systemd[1]: Started LSB: Start Jenkins at boot time.
geekflare@ubuntu:~$

Étape 6 : Configuration du port (facultatif)

Par défaut, Jenkins est exécuté sur 8080 port, et nous devons rendre ce port accessible de n'importe où (s'il n'est pas accessible).

Ouvrons le port: 

<span style="font-weight: 400;">sudo ufw allow 8080</span>

Nous pouvons vérifier l'état du port sous la commande suivante: 

<span style="font-weight: 400;">sudo ufw status</span>

geekflare@ubuntu:~$ sudo ufw status 
Status: active 
To           Action           From
--           ------           ---- 
8080         ALLOW            Anywhere 
8080 (v6)    ALLOW            Anywhere (v6) 
geekflare@ubuntu:~$

Si l'état du pare-feu est inactif, exécutez la commande suivante, sinon elle n'est pas requise 

<span style="font-weight: 400;">sudo ufw allow OpenSSH</span>

suivie par

<span style="font-weight: 400;">sudo ufw enable</span>

Jenkins Installation on CentOS

Tout d'abord, assurez-vous que JDK8 + est installé et fonctionne sur la machine. S'il n'est pas installé, exécutez la commande ci-dessous pour installer le package OpenJDK 8.

sudo yum install java-1.8.0-openjdk-devel
[geekflare@localhost ~]$ sudo yum install java-1.8.0-openjdk-devel
CentOS-8 - AppStream                            1.0 kB/s | 4.3 kB     00:04    
CentOS-8 - AppStream                            397 kB/s | 5.8 MB     00:14    
CentOS-8 - Base                                 3.5 kB/s | 3.9 kB     00:01    
CentOS-8 - Extras                               547  B/s | 1.5 kB     00:02    
Jenkins-stable                                  6.5 kB/s | 2.9 kB     00:00    
Dependencies resolved.
================================================================================
 Package                   Arch    Version                     Repository  Size
================================================================================
Installing:
 java-1.8.0-openjdk-devel  x86_64  1:1.8.0.252.b09-3.el8_2     AppStream  9.8 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 9.8 M
Installed size: 41 M
Is this ok [y/N]: y
Downloading Packages:
java-1.8.0-openjdk-devel-1.8.0.252.b09-3.el8_2. 531 kB/s | 9.8 MB     00:18    
--------------------------------------------------------------------------------
Total                                           507 kB/s | 9.8 MB     00:19     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : java-1.8.0-openjdk-devel-1:1.8.0.252.b09-3.el8_2.x86   1/1 
  Running scriptlet: java-1.8.0-openjdk-devel-1:1.8.0.252.b09-3.el8_2.x86   1/1 
  Verifying        : java-1.8.0-openjdk-devel-1:1.8.0.252.b09-3.el8_2.x86   1/1 
Installed products updated.

Installed:
  java-1.8.0-openjdk-devel-1:1.8.0.252.b09-3.el8_2.x86_64                       

Complete!
[geekflare@localhost ~]$

Pour vérifier que Java a été installé avec succès, exécutez la commande ci-dessous

java -version
[geekflare@localhost ~]$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
[geekflare@localhost ~]$

Une fois qu'il est installé, nous sommes prêts à installer Jenkins.

Procédure d'installation

Étape 1: Tout d'abord, ouvrez le terminal de commande

Étape 2: Pour installer Jenkins, tout d'abord, nous devons dtéléchargez et ajoutez la clé GPG Jenkins:

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
[geekflare@localhost ~]$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
--2020-06-21 04:29:52--  http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
Resolving pkg.jenkins-ci.org (pkg.jenkins-ci.org)... 52.202.51.185, 64:ff9b::34ca:33b9
Connecting to pkg.jenkins-ci.org (pkg.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85
Saving to: ‘/etc/yum.repos.d/jenkins.repo’

/etc/yum.repos.d/je 100%[==================>]      85  --.-KB/s    in 0s      

2020-06-21 04:29:54 (2.61 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85]

[geekflare@localhost ~]$

Étape 3: Après avoir téléchargé et ajouté la clé GPS Jenkins, nouvelle   Importer la clé GPG Jenkins:

sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

Étape 4: Mettre à jour les packages CentOS

sudo yum update
[geekflare@localhost ~]$ sudo yum update
Last metadata expiration check: 0:17:09 ago on Sun 21 Jun 2020 04:21:20 AM PDT.
Dependencies resolved.
Nothing to do.
Complete!
[geekflare@localhost ~]$

Étape 5: Après la mise à jour des packages centos, nous sommes prêts à installer, Jenkins: 

sudo yum install jenkins
[geekflare@localhost ~]$ sudo yum install jenkins
Last metadata expiration check: 0:19:26 ago on Sun 21 Jun 2020 04:21:20 AM PDT.
Dependencies resolved.
===============================================================================
 Package          Architecture    Version               Repository        Size
===============================================================================
Installing:
 jenkins          noarch          2.235.1-1.1           jenkins           63 M

Transaction Summary
===============================================================================
Install  1 Package

Total download size: 63 M
Installed size: 63 M
Is this ok [y/N]: y
Downloading Packages:
jenkins-2.235.1-1.1.noarch.rpm                 172 kB/s |  63 MB     06:16    
-------------------------------------------------------------------------------
Total                                          172 kB/s |  63 MB     06:16     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                       1/1 
  Running scriptlet: jenkins-2.235.1-1.1.noarch                            1/1 
  Installing       : jenkins-2.235.1-1.1.noarch                            1/1 
  Running scriptlet: jenkins-2.235.1-1.1.noarch                            1/1 
  Verifying        : jenkins-2.235.1-1.1.noarch                            1/1 
Installed products updated.

Installed:
  jenkins-2.235.1-1.1.noarch                                                   

Complete!
[geekflare@localhost ~]$

Étape 6: Démarrer Jenkins systemctl 

sudo systemctl start jenkins

Depuis que systemctl n'affiche pas la sortie afin que vous puissiez vérifier l'état via la commande ci-dessous. Et grâce à cette commande, vous pouvez vérifier si Jenkins est actif ou non. 

sudo systemctl status jenkins
[geekflare@localhost ~]$ sudo systemctl status jenkins
[sudo] password for geekflare: 
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
   Active: active (running)
     Docs: man:systemd-sysv-generator(8)

Jun 20 11:15:22 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automa>
Jun 20 11:15:23 localhost.localdomain runuser[1456]: pam_unix(runuser:session)>
Jun 20 11:15:33 localhost.localdomain jenkins[1433]: Starting Jenkins [  OK  ]
Jun 20 11:15:33 localhost.localdomain systemd[1]: Started LSB: Jenkins Automat>
Jun 21 04:23:04 localhost.localdomain systemd[1]: Stopping LSB: Jenkins Automa>
[geekflare@localhost ~]$

Étape 7: Configuration du port (facultatif)

Par défaut, Jenkins est exécuté sur le port 8080, et nous devons rendre ce port accessible de n'importe où (uniquement s'il n'est pas accessible). Ouvrons le port,

sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
[geekflare@localhost ~]$ sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
success
[geekflare@localhost ~]$

Après avoir configuré le pare-feu de rechargement de port, 

sudo firewall-cmd --reload
[geekflare@localhost ~]$ sudo firewall-cmd --reload
success
[geekflare@localhost ~]$

Configuring Jenkins

Une fois Jenkins installé, il fonctionnera sur le port 8080  Configurons-le en accédant à http://localhost:8080 sur notre navigateur préféré.

Step-1: Visite http://localhost:8080

Step-2: Pour déverrouiller le Jenkins, copiez le mot de passe administrateur du fichier situé à

  • Pour Windows

C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword

/var/lib/jenkins/secrets/initialAdminPassword

Maintenant, collez-le dans le Mot de passe administrateur champ. Ensuite, cliquez sur le Continuer .

Step-3: Vous pouvez installer des plugins suggérés ou vous pouvez sélectionner des plugins en fonction de votre cas d'utilisation. Ici, nous installerons les plugins suggérés. 

Step-4: Veuillez attendre que tous les plugins soient installés. Une fois l'installation terminée, cliquez sur Continuer.

Step-5: Créez un profil d'administrateur pour Jenkins. Entrez les détails requis et cliquez sur Sauvegarder et continuer.

Step-6: Nous pouvons changer l'URL Jenkins si nécessaire, gardons-la par défaut http://localhost:8080Cliquez sur Enregistrer et terminer pour terminer le processus de configuration. Maintenant, cliquez sur Commencez à utiliser Jenkins

Enfin, le processus de configuration est terminé, et celui ci-dessus est celui par défaut, Bienvenue à Jenkins! Venez voir des images qui vous inspireront.

L'étape de configuration Jenkins est similaire pour tous les systèmes d'exploitation, sauf Étape 2 où nous devons récupérer et entrer le mot de passe administrateur. Ce mot de passe peut être récupéré à partir du fichier, stocké dans le chemin indiqué dans Déverrouiller l'interface utilisateur Jenkins.

Conclusion

Donc, les étapes ci-dessus étaient pour installer Jenkins sur votre système d'exploitation préféré. Ensuite, apprenez à créer votre premier Pipelines Jenkins.

L'installation de Jenkins est facile et si vous configurez l'équipe distante, vous pouvez soit en obtenir VM cloud et installez-le vous-même ou optez pour Plateforme d'hébergement Jenkins.

Merci à nos commanditaires
Plus de bonnes lectures sur le développement
Alimentez votre entreprise
Certains des outils et services pour aider votre entreprise à se développer.
  • Invicti utilise Proof-Based Scanning™ pour vérifier automatiquement les vulnérabilités identifiées et générer des résultats exploitables en quelques heures seulement.
    Essayez Invicti
  • Web scraping, proxy résidentiel, proxy manager, web unlocker, moteur de recherche et tout ce dont vous avez besoin pour collecter des données Web.
    Essayez Brightdata
  • Semrush est une solution de marketing numérique tout-en-un avec plus de 50 outils de référencement, de médias sociaux et de marketing de contenu.
    Essayez Semrush
  • Intruder est un scanner de vulnérabilités en ligne qui détecte les failles de cybersécurité de votre infrastructure, afin d'éviter des violations de données coûteuses.
    Essayez Intruder