понедельник, 27 января 2020 г.

Jenkins: более гибкие возможности с freestyle configuration

При работе с freestyle configuration часто встают вопросы переноса конфигураций, их архивирования, контроле версий и прочем. Они конечно доступны в xml формате, но работа "напрямую" крайне неудобна. Плюс нет механизмов контроля подключённых плагинов, нужно отдельно получать их список с версиями и носить в отдельных файлах. Но если нет возможности перейти на pipeline, есть плагины, облегчающие жизнь.

Jenkins Job Builder

Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML or JSON format and uses them to configure Jenkins. You can keep your job descriptions in human readable text format in a version control system to make changes and auditing easier. It also has a flexible template system, so creating many similarly configured jobs is easy.
https://docs.openstack.org/infra/jenkins-job-builder/index.html

То есть этакий недо-пайплайн, но со своими преимуществами
- умеет создавать любые типы джоб
- позволяет хранить все джобы в одном проекте (и это не тоже самое что хранить пачку JenkinsfileXXX)
- позволяет описать джобы ямлом
- шаблонизируется

git clone https://opendev.org/jjb/jenkins-job-builder.git

job-dsl

Jenkins is a wonderful system for managing builds, and people love using its UI to configure jobs. Unfortunately, as the number of jobs grows, maintaining them becomes tedious, and the paradigm of using a UI falls apart. Additionally, the common pattern in this situation is to copy jobs to create new ones, these "children" have a habit of diverging from their original "template" and consequently it becomes difficult to maintain consistency between these jobs.

The Job DSL plugin attempts to solve this problem by allowing jobs to be defined in a programmatic form in a human readable file. Writing such a file is feasible without being a Jenkins expert as the configuration from the web UI translates intuitively into code.


https://jenkinsci.github.io/job-dsl-plugin/#path/freeStyleJob

JCasC

Experienced Jenkins users rely on groovy init scripts to customize Jenkins and enforce desired state. Those scripts directly invoke Jenkins API and as such can do everything (at your own risk). But they also require you know Jenkins internals, and are confident in writing groovy scripts on top of Jenkins API.

The Configuration as Code plugin has been designed as an opinionated way to configure Jenkins based on human-readable declarative configuration files. Writing such a file should be feasible without being a Jenkins expert, just translating into code a configuration process one is used to executing in the web UI.

Он не умеет в плагины (убрали такую возможность), поэтому дальше следущий модуль

configuration-as-code-groovy-plugin

Extension for Jenkins Configuration-as-Code plugin that allows running Groovy scripts

https://plugins.jenkins.io/configuration-as-code-groovy

Мини итог
плагины отдельным списком
конфиг в jcasc, джобы - в jjb
и не надо трястись над бекапами мастера .

Комментариев нет:

Отправить комментарий