User Tools

Site Tools


инструмент_jenkins

Инструмент Jenkins

Установка

  • !!! В текущей версии устанавливается так:
# 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

Смена порта

server# systemctl stop jenkins

server# systemctl edit jenkins
[Service]
Environment="JENKINS_PORT=8081"
server# systemctl start jenkins

server# systemctl status jenkins
Dashboard -> Manage Jenkins -> System
  Jenkins URL: http://server.corpX.un:8081/

Подключение

Подключение агента

  • !!! В текущей версии нужно: Dashboard → Manage Jenkins → Security → TCP port for inbound agents: Random
gate# useradd -m -s /bin/bash jenkins
Dashboard->Set up an agent->Create a new node 
  Node name: gate
  Type: Permanent Agent
  ...
  Remote root directory: /home/jenkins/
  ...
  Use WebSocket: yes   !!! В текущей версии нет
  ...
gate# su - jenkins
Копируем команды, указанные на странице нового агента:

jenkins@gate:~$ curl -sO http://server.corpX.un:8081/jnlpJars/agent.jar

jenkins@gate:~$ java -jar agent.jar -jnlpUrl http://server.corpX.un:8081/computer/gate/jenkins-agent.jnlp -secret NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -workDir "/home/jenkins/"

Примеры проектов/заданий

Freestyle projects

Enter an item name:
  dhcp freestyle project
...
Restrict where this project can be run:
  gate
...
Source Code Management:
  Git:
    Repository URL: http://server.corpX.un:3000/student/dhcp.git
...    
Build Steps
  Execute shell:
    make test
  Execute shell:
    sudo make install
...
Dashboard -> dhcp freestyle project
  Build Now

Pipeline

Enter an item name:
  dhcp pipeline
...
Pipeline
  Pipeline script from SCM
    Repository URL: http://server.corpX.un:3000/student/dhcp.git
В SCM GitLab/GitHub/Gitea:

New File: Jenkinsfile
pipeline {
    agent {
        node {
            label 'gate' 
        }
    }
    stages {
        stage('Test') {
            steps {
                sh 'make test'
            }
        }
        stage('Deploy') {
            steps {
                sh 'sudo make install'
            }
        }
    }
}

Webhooks

Manage Jenkins -> Manage Plugins -> Available -> Gitea
Manage Jenkins -> Configure System -> Gitea Servers
  Name: server
  Server URL: http://server.corpX.un:3000/
  Manage hooks
    Jenkins Credentials Provider: Jenkins
    Login: student
    ...
Freestyle dhcp
  или
Pipeline dhcp

  Configure
    Poll SCM: yes
Gitea
  Project->Setings->Webhooks
    Должен появиться Target URL и работать Test Delivery
    
Задержка, примерно, 30 секунд
инструмент_jenkins.txt · Last modified: 2024/04/08 18:53 by val