This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
инструмент_jenkins [2023/09/15 05:28] val [Установка] |
инструмент_jenkins [2024/09/19 08:20] (current) val [Запуск агента через SSH] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Инструмент Jenkins ====== | ====== Инструмент Jenkins ====== | ||
- | * [[https://hevodata.com/learn/gitlab-webhook-jenkins-integration/|GitLab Webhook Jenkins Integration: Automating Jobs Simplified 101]] | + | * [[https://www.jenkins.io/doc/book/system-administration/admin-password-reset-instructions/|Reset the administrator password]] |
- | * [[https://gcube.wiki.gcube-system.org/gcube/Gitea/Jenkins:_Setting_up_Webhooks|Gitea/Jenkins: Setting up Webhooks]] | + | |
===== Установка ===== | ===== Установка ===== | ||
- | * [[Сервис JRE]] | + | * [[Сервис JRE]] |
* [[https://www.jenkins.io/doc/book/installing/linux/|Debian/Ubuntu Long Term Support release]] | * [[https://www.jenkins.io/doc/book/installing/linux/|Debian/Ubuntu Long Term Support release]] | ||
+ | * [[https://pkg.jenkins.io/debian-stable/]] | ||
+ | ==== !!! Обратитесь к преподавателю !!! ==== | ||
+ | * В текущей версии устанавливается так: | ||
+ | <code> | ||
+ | # wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | ||
+ | |||
+ | # echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ | ||
+ | https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ | ||
+ | /etc/apt/sources.list.d/jenkins.list > /dev/null | ||
+ | | ||
+ | # apt-get update | ||
+ | |||
+ | # apt-get install fontconfig openjdk-17-jre | ||
+ | |||
+ | # apt-get install jenkins | ||
+ | </code> | ||
==== Смена порта ==== | ==== Смена порта ==== | ||
Line 36: | Line 51: | ||
* [[https://medium.com/@med446/setting-up-a-jenkins-slave-a7000358c557|Setting up a Jenkins Agent]] | * [[https://medium.com/@med446/setting-up-a-jenkins-slave-a7000358c557|Setting up a Jenkins Agent]] | ||
- | * [[https://www.jenkins.io/blog/2022/12/27/run-jenkins-agent-as-a-service/|Create a new Jenkins node, and run your Jenkins agent as a service]] | + | |
* [[Сервис JRE]] | * [[Сервис JRE]] | ||
Line 43: | Line 58: | ||
</code> | </code> | ||
* [[Пакет sudo]] | * [[Пакет sudo]] | ||
+ | ==== Агент подключается к контроллеру ==== | ||
+ | |||
+ | * !!! В текущей версии нужно: Dashboard -> Manage Jenkins -> Security -> TCP port for inbound agents: Random | ||
+ | * Требуется [[https://plugins.jenkins.io/instance-identity/|Instance Identity]] plugin | ||
+ | |||
+ | |||
<code> | <code> | ||
Dashboard->Set up an agent->Create a new node | Dashboard->Set up an agent->Create a new node | ||
Line 50: | Line 71: | ||
Remote root directory: /home/jenkins/ | Remote root directory: /home/jenkins/ | ||
... | ... | ||
- | Use WebSocket: yes | + | Способ запуска |
+ | Запустить агент, подключив его к контроллеру | ||
... | ... | ||
</code><code> | </code><code> | ||
Line 60: | Line 82: | ||
jenkins@gate:~$ java -jar agent.jar -jnlpUrl http://server.corpX.un:8081/computer/gate/jenkins-agent.jnlp -secret NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -workDir "/home/jenkins/" | jenkins@gate:~$ java -jar agent.jar -jnlpUrl http://server.corpX.un:8081/computer/gate/jenkins-agent.jnlp -secret NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -workDir "/home/jenkins/" | ||
+ | ... | ||
+ | INFO: Connected | ||
+ | </code> | ||
+ | |||
+ | * [[https://www.jenkins.io/blog/2022/12/27/run-jenkins-agent-as-a-service/|Create a new Jenkins node, and run your Jenkins agent as a service]] | ||
+ | * [[Управление сервисами в Linux#Система загрузки Systemd]] | ||
+ | |||
+ | ==== Запуск агента через SSH ==== | ||
+ | |||
+ | * Требуется [[https://plugins.jenkins.io/ssh-slaves/|SSH Build Agents]] plugin | ||
+ | |||
+ | <code> | ||
+ | gate# passwd jenkins | ||
+ | </code> | ||
+ | <code> | ||
+ | Dashboard->Set up an agent->Create a new node | ||
+ | Node name: gate | ||
+ | Type: Permanent Agent | ||
+ | ... | ||
+ | Remote root directory: /home/jenkins/ | ||
+ | ... | ||
+ | Способ запуска | ||
+ | Launch Agent via SSH | ||
+ | ... | ||
+ | Host: gate | ||
+ | Credentials ... | ||
+ | Host Key Verification Strategy: Non ... | ||
+ | ... | ||
</code> | </code> | ||
Line 75: | Line 125: | ||
Git: | Git: | ||
Repository URL: http://server.corpX.un:3000/student/dhcp.git | Repository URL: http://server.corpX.un:3000/student/dhcp.git | ||
- | ... | + | ... |
+ | Branch Specifier: */* | ||
+ | ... | ||
Build Steps | Build Steps | ||
Execute shell: | Execute shell: | ||
Line 82: | Line 134: | ||
sudo make install | sudo make install | ||
... | ... | ||
+ | </code><code> | ||
+ | Dashboard -> dhcp freestyle project | ||
+ | Build Now | ||
</code> | </code> | ||
==== Pipeline ==== | ==== Pipeline ==== | ||
+ | * !!! В первый раз обязательно запустить "вручную" | ||
* [[https://www.jenkins.io/doc/book/pipeline/getting-started/|Getting started with Pipeline]] | * [[https://www.jenkins.io/doc/book/pipeline/getting-started/|Getting started with Pipeline]] | ||
Line 93: | Line 149: | ||
Pipeline | Pipeline | ||
Pipeline script from SCM | Pipeline script from SCM | ||
- | Repository URL: http://server.corp13.un:3000/student/dhcp.git | + | Repository URL: http://server.corpX.un:3000/student/dhcp.git |
+ | |||
+ | Branches to build: */* | ||
</code> | </code> | ||
Line 126: | Line 184: | ||
==== Webhooks ==== | ==== Webhooks ==== | ||
+ | * [[https://hevodata.com/learn/gitlab-webhook-jenkins-integration/|GitLab Webhook Jenkins Integration: Automating Jobs Simplified 101]] | ||
* [[https://gcube.wiki.gcube-system.org/gcube/Gitea/Jenkins:_Setting_up_Webhooks|Gitea/Jenkins: Setting up Webhooks]] | * [[https://gcube.wiki.gcube-system.org/gcube/Gitea/Jenkins:_Setting_up_Webhooks|Gitea/Jenkins: Setting up Webhooks]] | ||
+ | |||
<code> | <code> | ||
Manage Jenkins -> Manage Plugins -> Available -> Gitea | Manage Jenkins -> Manage Plugins -> Available -> Gitea | ||
</code> | </code> | ||
+ | |||
+ | * [[Инструмент Gitea#Файл конфигурации]] Gitea: ALLOWED_HOST_LIST | ||
<code> | <code> | ||
Manage Jenkins -> Configure System -> Gitea Servers | Manage Jenkins -> Configure System -> Gitea Servers | ||
Name: server | Name: server | ||
- | Server URL: http://server.corp13.un:3000/ | + | Server URL: http://server.corpX.un:3000/ |
Manage hooks | Manage hooks | ||
Jenkins Credentials Provider: Jenkins | Jenkins Credentials Provider: Jenkins | ||
Line 148: | Line 210: | ||
Poll SCM: yes | Poll SCM: yes | ||
</code> | </code> | ||
- | |||
- | * [[Инструмент Gitea#Файл конфигурации]] Gitea: ALLOWED_HOST_LIST | ||
<code> | <code> | ||
Gitea | Gitea | ||
- | Project->Setings-Webhooks | + | Project->Setings->Webhooks |
Должен появиться Target URL и работать Test Delivery | Должен появиться Target URL и работать Test Delivery | ||
| | ||
Задержка, примерно, 30 секунд | Задержка, примерно, 30 секунд | ||
</code> | </code> |