user971741
user971741

Reputation:

Changes not triggering workflow and jobs based on defined condition

I have following workflow configurations:

workflow:
  rules:
    - if: '$CI_COMMIT_REF_NAME == "master"'
      changes:
        - /*script.yaml
    
variables:
  CI_COMMIT_TIMESTAMP: $CI_COMMIT_TIMESTAMP
  ROOT_DIR: ${CI_PROJECT_DIR}
  SCRIPT_PATH: /etc/executable/scripts/
  A_REPOSITORY_SCRIPT_PATH: /folder/a/script.yaml
  B_REPOSITORY_SCRIPT_PATH: /folder/b/script.yaml


stages:
  - init

# A Workflow:  
deploycheck a 1/6:
  rules:
    - changes:
      - ${A_REPOSITORY_SCRIPT_PATH}
  stage: init
  script: |
    [ -f "${SCRIPT_PATH}/script.yaml" ] && cp -v "${SCRIPT_PATH}/script.yaml" ${SCRIPT_PATH}/SCRIPT_yaml_$CI_COMMIT_TIMESTAMP.txt

# B Workflow:    
deploycheck b 1/6:
  rules:
    - changes:
      - ${B_REPOSITORY_SCRIPT_PATH}
  stage: init
  script: |
    [ -f "${SCRIPT_PATH}/script.yaml" ] && cp -v "${SCRIPT_PATH}/script.yaml" ${SCRIPT_PATH}/SCRIPT_yaml_$CI_COMMIT_TIMESTAMP.txt

I want this workflow to trigger when a change is made to any script.yaml file anywhere inside the repository and pushed to master branch.

And once the workflow is triggers depending on the path and which script.yaml was changes respective jobs should run.

However, nothing happens with this and no matter which script.yaml I change this workflow never gets triggered.

What am I missing here?

Upvotes: 0

Views: 492

Answers (1)

sytech
sytech

Reputation: 40861

Your glob pattern would only match the root directory.

To match in any directory, use "**/script.yaml"

Upvotes: 0

Related Questions