【问题标题】:run delay job conditionally gitlab ci有条件地运行延迟作业 gitlab ci
【发布时间】:2022-08-20 01:25:32
【问题描述】:

有条件地运行延迟作业 gitlab ci 管道

阶段:超时1

timeout1:
  dependencies:
    - prepare_tag
  rules:
    - if: $TIMER == \"3 days\"
      when: delayed
      start_in: 1 minute
    - if: $TIMER == \"2 days\"
      when: always
      start_in: 2 minutes
  script:
    - echo -e \"$TIMER\"
  stage: timeout1

    标签: gitlab continuous-integration


    【解决方案1】:

    我能够使用 gitlab ci 动态子管道来实现这一点

    create_timeout_pipeline:
      stage: create_timeout_pipeline
      script:
      - echo -e "$flag"
      - CURRENT=$(date +%s)
      - FUTURE=$(date --date "$flag 1446 minutes ago" +%s)
      - ANS=$((FUTURE - CURRENT)) 
      - |
        cat > dynamic.yml << EOF
        timeout_job:
          script:
            - ls
          when: delayed
          start_in: ${ANS} seconds
        EOF
      artifacts:
        paths:
          - dynamic.yml
    
    ### stage: timeout_job #########################################################
    timeout_job:
      stage: timeout_job
      trigger:
        include:
          - artifact: dynamic.yml
            job: create_timeout_pipeline
        strategy: depend
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      • 1970-01-01
      相关资源
      最近更新 更多