DO-63/Waydroid_build (#1)

+ Added jobs-dsl and gitea events
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Co-committed-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
This commit is contained in:
aleksandr.vodyanov
2023-09-25 12:01:22 +00:00
committed by Aleksandr Vodyanov
parent 70e286b008
commit 9046f994f1
9 changed files with 301 additions and 28 deletions

View File

@@ -1,38 +1,72 @@
# jenkins-pipeline-shared-lib
# Jenkins pipelines
### Docs:
Репозиторий с пайплайнами Avroid
[Jenkins Shared Libraries](https://www.jenkins.io/doc/book/pipeline/shared-libraries/)
---
[Pipeline CPS Method Mismatches](https://www.jenkins.io/doc/book/pipeline/cps-method-mismatches/)
Джобы в репозитории должны соответствовать той же ирархии каталогов что и
в **Jenkins**.
[Pipeline Best Practices](https://www.jenkins.io/doc/book/pipeline/pipeline-best-practices/)
[Документирование классов в Java](https://java-online.ru/java-javadoc.xhtml)
### Directory structure
The directory structure of a Shared Library repository is as follows:
```
(root)
+- src # Groovy source files
| +- org
| +- foo
| +- Bar.groovy # for org.foo.Bar class
+- vars
| +- foo.groovy # for global 'foo' variable
| +- foo.txt # help for 'foo' variable
+- resources # resource files (external libraries only)
| +- org
| +- foo
| +- bar.json # static helper data for org.foo.Bar
```bash
├── jobs-dsl
│ ├── folders
│ │ └── Docker.groovy
│ ├── jobs
│ │ └── Docker
│ │ └── build_docker_image.groovy
│ └── views
│ └── devops.groovy
└── pipelines
└── Docker
└── build_docker_image.groovy
```
The `src` directory should look like standard Java source directory structure. This directory is added to the classpath when executing Pipelines.
На изображении выше показана иерархия рабочих каталогов:
Каталог **jobs-dsl** содержит в себе 3 каталога folders, jobs, views.
В каждом из них содержиться описание сущностей jenkins.
The `vars` directory hosts script files that are exposed as a variable in Pipelines. The name of the file is the name of the variable in the Pipeline. So if you had a file called `vars/log.groovy` with a function like `def info(message)…` in it, you can access this function like `log.info "hello world"` in the Pipeline. You can put as many functions as you like inside this file. Read on below for more examples and options.
Далее идет каталог **pipelines**, в нем содержаться рабочии пайплайны.
The basename of each `.groovy` file should be a Groovy (~ Java) identifier, conventionally `camelCased`. The matching `.txt`, if present, can contain documentation, processed through the systems configured markup formatter (so may really be HTML, Markdown, etc., though the `.txt` extension is required). This documentation will only be visible on the Global Variable Reference pages that are accessed from the navigation sidebar of Pipeline jobs that import the shared library. In addition, those jobs must run successfully once before the shared library documentation will be generated.
После создания джобы **pipeline**, необходимо добавить **job dsl** в директории **jobs-dsl**
The Groovy source files in these directories get the same “CPS transformation” as in Scripted Pipeline.
---
A `resources` directory allows the `libraryResource` step to be used from an external library to load associated non-Groovy files. Currently this feature is not supported for internal libraries.
## jenkins-job-dsl
Репозиторий для реализации методологии **IaC** для управления задачами в Jenkins
c использованием плагина [Job DSL](https://plugins.jenkins.io/job-dsl/)
[Ссылка](https://jenkins.devos.club/plugin/job-dsl/api-viewer/index.html) на локальную документацию.
Джобы **dsl** должны называться через "_" пробелы и "-" запрещены, потому что у **job dsl** проблемы с парсингом.
---
## Триггер джобы jobs-dsl
Джоба [jobs-dsl](https://jenkins.avroid.tech/job/jobs-dsl/job/jobs-dsl/) вызывается через джобу [jobs-runner](https://jenkins.avroid.tech/job/gitea-events/job/jobs-runner/), которая
в свою очередь вызывается по **webhook** из **gitea**.
---
## WebHook job
В репозитории есть [джоба](pipelines/gitea-events/jobs-runner.groovy) которая запускает
другие джобы в зависомости от условий.
Джоба имеет следующий мапинг
```bash
Map projects = [
// при такой конфигурации будет запускаться только одна джоба с проекта 'devops/jenkins-pipeline-shared-lib'
// из мастер ветки. Можно добавлять сюда еще и другие ветки.
'devops/jenkins-pipeline-shared-lib': [
'branches': ['master'],
'jobs': ['Docs/create_shared_libs_docs']
],
// при такой конфигурации будет запускаться только одна джоба с проекта 'antiq/tsnative' на любой ветке
'antiq/tsnative': [
'branches': [],
'jobs': ['gitea-events/add-git-tags-to-jira']
]
]
```