Merge branch 'fix-pipeline-submodule' into 'development'

fix: pipeline submodule

See merge request nofusscomputing/projects/gitlab-ci!48
This commit is contained in:
2023-06-03 01:36:14 +00:00
2 changed files with 74 additions and 17 deletions

View File

@ -22,6 +22,52 @@ include:
- echo "[DEBUG] ansible_playbook=$ansible_playbook"
- echo "[DEBUG] ansible_tags=$ansible_tags"
- ansible-playbook $ansible_inventory $ANSIBLE_PLAYBOOK_DIR/$ansible_playbook $ansible_tags -vvv
rules:
# ToDo: at some stage redefine these rules so that the job can run if specified.
# - if: '$NFC_AUTO_JOBS == "false"'
# when: never
# - if: '$CI_PIPELINE_SOURCE == "schedule" && $PIPELINE_RUN_SCHEDULE == "true"'
# exists:
# - ".nfc_automation.yaml"
# when: always
# - if:
# (
# $CI_PIPELINE_SOURCE == "api"
# ||
# $CI_PIPELINE_SOURCE == "pipeline"
# ||
# $CI_PIPELINE_SOURCE == "trigger"
# ||
# $CI_PIPELINE_SOURCE == "parent_pipeline"
# ) &&
# $PIPELINE_RUN_TRIGGER == "true"
# exists:
# - ".nfc_automation.yaml"
# when: always
# - if: # condition_dev_branch_push
# $CI_COMMIT_BRANCH == "development" &&
# $CI_PIPELINE_SOURCE == "push"
# exists:
# - ".nfc_automation.yaml"
# when: always
# # this if for testing only
# # - if: '$CI_PIPELINE_SOURCE == "push"'
# # when: always
# # exists:
# # - ".nfc_automation.yaml"
- when: never
.ansible_playbook_git_submodule:
extends: .ansible_playbook
variables:
ansible_playbook: 'git_configuration.yaml'
ansible_tags: 'submodule'
rules:
- if: '$NFC_AUTO_JOBS == "false"'
when: never
@ -58,29 +104,43 @@ include:
# when: always
# exists:
# - ".nfc_automation.yaml"
- when: never
- when: never
.submodule_update_trigger:
stage: publish
trigger:
project: $SUBMODULE_UPDATE_TRIGGER_PROJECT
branch: development
forward:
yaml_variables: false
# trigger:
# project: $SUBMODULE_UPDATE_TRIGGER_PROJECT
# branch: development
# inherit:
# variables: false
script:
# use script to trigger pipeline instead of trigger keyword.
# this is due to trigger keyword not allowing environment keyword.
- export TRIGGER_PROJECT_PATH=$(python3 -c "import urllib.parse, sys; print('$SUBMODULE_UPDATE_TRIGGER_PROJECT'.replace('/', '%2F'))")
- echo "[DEBUG] TRIGGER_PROJECT_PATH=$TRIGGER_PROJECT_PATH"
- |
curl \
--request POST \
--form "token=$CI_JOB_TOKEN" \
--form ref=development \
--form "variables[GIT_CONFIG_SUBMODULE_NAME]=$GIT_CONFIG_SUBMODULE_NAME" \
--form "variables[PIPELINE_RUN_TRIGGER]=$PIPELINE_RUN_TRIGGER" \
"https://gitlab.com/api/v4/projects/$TRIGGER_PROJECT_PATH/trigger/pipeline"
environment:
name: $SUBMODULE_UPDATE_TRIGGER_PROJECT
url: https://gitlab.com/$SUBMODULE_UPDATE_TRIGGER_PROJECT
variables:
PIPELINE_RUN_TRIGGER: 'true'
GIT_CONFIG_SUBMODULE_NAME: $CI_PROJECT_NAME
rules:
- if: $CI_COMMIT_TAG
when: never
- if: # condition_master_or_dev_push
(
$CI_COMMIT_BRANCH == "master" ||
$CI_COMMIT_BRANCH == "development"
)&&
$CI_PIPELINE_SOURCE == "push"
) &&
$CI_PIPELINE_SOURCE == "push" &&
$CI_COMMIT_TAG == null
when: on_success
- when: never
- when: never

View File

@ -30,11 +30,8 @@ include:
# Chores
#
Update Git Submodules:
extends: .ansible_playbook
variables:
ansible_playbook: 'git_configuration.yaml'
ansible_tags: 'submodule'
extends: .ansible_playbook_git_submodule
#
# Release