最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

continuous integration - GitLab CI job with inputs to configure a matrix trigger job - Stack Overflow

programmeradmin0浏览0评论

I'm trying to write a GitLab CI/CD pipeline job that is part of a GitLab Component project. Specifically, this job is designed to trigger a multi-project pipeline, but I want the pipeline(s) to be triggered to be defined as an input by the user. And importantly, if the user has nothing to trigger, this job should have a rule that excludes it from the pipeline. The following is how I'm constructing this.

spec:
  inputs:
    trigger-projects:
      type: array
      default: []

---

trigger dependency validation:
  stage: build
  rules:
    - if: $[[ inputs.trigger-projects ]]  # GitLab takes umbrage here
      changes: [my_file]
  parallel:
    matrix:
      - PROJECT: $[[ inputs.trigger-projects ]] # GitLab also takes umbrage here
        VARIABLE_TO_PASS_ON: "VALUE"
  trigger:
    project: ${PROJECT}
    strategy: depend

The expectation for above is that if the user never defines trigger-projects when this job is included, the rules section will see an empty array and should evaluate to false, preventing this job from being included. Here's the first issue. I cannot determine a valid if statement to check if the input array is non-empty. If I circumvent this issue by creating a second boolean input (less desirable) to just include or disclude this job, then GitLab seems to dislike trying to assign an array to the PROJECT variable in the matrix section.

Is it possible to do what I'm trying to do?

发布评论

评论列表(0)

  1. 暂无评论