Из коробки может быть запущен только один экземпляр GitLab Runner. Это можно обойти с помощью Docker. Но зачем? :)
Один GitLab Runner может обслуживать неограниченное количество executor'ов.
| # Добавить в пайплайн задание с ручным запуском для тестирование инфраструктуры | |
| # если изменился файл .gitlab-ci.yml или название ветки начинается с infrastructure | |
| test:infrastructure: | |
| stage: test | |
| rules: | |
| - changes: | |
| - .gitlab-ci.yml | |
| when: manual | |
| - if: '$CI_COMMIT_REF_NAME =~ /^infrastructure\/.*$/i' | |
| when: manual |
| # Получить адрес хоста по его имени в Ansible inventory | |
| host_address=`ansible --inventory ansible/inventories/hosts.yml \ | |
| --module-name debug --args msg="{{ hostvars['host-name'].ansible_host }}" \ | |
| --one-line localhost | sed -E 's/.+"msg":\s"(.+)".+/\1/'` |
| def commonModule | |
| pipeline { | |
| agent { label 'runner-1' } | |
| stages { | |
| stage('Preparation') { | |
| steps { | |
| script { | |
| commonModule = load 'Jenkinsfile.common' | |
| } |
| - name: Disable and stoping service if exists | |
| systemd: | |
| service: "{ service name }" | |
| enabled: no | |
| state: stopped | |
| register: result_systemd_stop | |
| failed_when: "result_systemd_stop is failed and 'Could not find the requested service' not in result_systemd_stop.msg" |
| # Исключить все файлы и каталоги | |
| ** | |
| # ... кроме следующих: | |
| !Pipfile | |
| !Pipfile.lock | |
| !main.py |
| cd path-to-git-repository | |
| if [ `git log --pretty=%H ...refs/heads/master^` == `git ls-remote origin -h refs/heads/master | cut -f1` ]; then | |
| exit 1; | |
| fi | |
| git pull |