2

I have a problem with gitlab ci child pipelines. Need to trigger ci pipeline automatically after each commit in repo that have more than one app. Need to configure to detect which folder/files were modified in order to know which app pipeline to trigger

Example of structure

Main/ ---- applicationsA/ -------- appA1/ -------- appA2/ -------- appA3/ ---- applicationsB/ -------- appB1/ -------- appB2/ -------- appB3/ 

Main ".gitlab-ci.yml" is:

 workflow: rules: - if: ‘$CI_PIPELINE_SOURE == “web”’ variables: APPNAME: $APPNAME stages: - child-pipelines appA1: stage: child-pipelines trigger: include: - local: applicationA/appA1/gitlab-ci.yml strategy: depend rules: - if: $APPNAME == “appA1” && $CI_PIPELINE_SOURE == “web” appA2: stage: child-pipelines trigger: include: - local: applicationA/appA2/gitlab-ci.yml strategy: depend rules: - if: $APPNAME == “appA1” && $CI_PIPELINE_SOURE == “web” ... 

appA1 ".gitlab-ci.yml" is:

 stages: - build - test build-appA1: stage: build script: - echo "Execute appA1 build!" publish-appA1: stage: build script: - echo "Execute appA1 publish!" 

appA2 ".gitlab-ci.yml" is:

 stages: - build - test build-appA2: stage: build script: - echo "Execute appA1 build!" publish-appA2: stage: build script: - echo "Execute appA1 publish!" 

The purpose of this configuration is that , for example, when i change a file inside app**, the pipeline detects the changes and build the app**.

2
  • Something off with the quotes . I have a problem What problem? Commented Feb 24, 2022 at 11:07
  • there are different keywords in Gitlab CI/CD like when, you should take a look at those that can help. link Commented Feb 24, 2022 at 11:08

1 Answer 1

1

You can use rules:changes with a glob pattern and only run a certain job if anything changes in the specific app folder:

appA1: stage: child-pipelines trigger: include: - local: applicationA/appA1/gitlab-ci.yml strategy: depend rules: - if: '$APPNAME == "appA1" && $CI_PIPELINE_SOURE == "web"' changes: - Main/applicationsA/appA1/**/* 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for you response. Is it possible to use rules:changes with rules: if: $APPNAME == “appA1” && $CI_PIPELINE_SOURE == “web”?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.