gitlab-ci - Gitlab/CI 作业规则评估
问题描述
我正在尝试根据上一个作业的结果跳过 GitLab ci 作业,但是,因此,该作业永远不会运行。我的印象是规则是在流水线开始而不是在作业开始时评估的。有什么办法让它工作吗?
cache:
paths:
- .images
stages:
- prepare
- build
dirs:
stage: prepare
image:
name: docker.image.me/run:latest
script:
- rm -rf .images/*
- [ $(($RANDOM % 2)) -eq 1 ] && touch .images/DESKTOP
desktop:
stage: build
needs: ["dirs"]
image:
name: docker.image.me/run:latest
rules:
- exists:
- .images/DESKTOP
when: always
script:
- echo "Why is this never launched?"
解决方案
动态创建的工作可能是一种解决方案(https://docs.gitlab.com/ee/ci/parent_child_pipelines.html#dynamic-child-pipelines)。
如果创建了“.images/DESKTOP”,您可以在“dirs”-job 的“script”部分创建一个带有“desktop”-job 的 yml 文件。否则您创建的 yml 文件应该是空的。
创建的 yml 文件可以在“dirs”-job 之后的单独作业中触发。
我用于创建动态子管道 jsonnet ( https://jsonnet.org/ )。
推荐阅读
- swift - 如何将闪烁动画应用于 TextView 内的文本?
- reactjs - React.js setState 不起作用。渲染问题
- database - 如何从带有“case”的表中创建表,以便在 Oracle 中复制和修改原始数据?
- javascript - 如何调用回调直接修复 React 类组件中的“this”?
- angular - 使用 angular-cli-ghpages 部署 Scully 静态文件夹?
- sql - 如何在 PostgreSQL 中的 jsonb 列的元素上使用 LOWER()?
- react-native - 使用 webview 发送参数 - React Native
- flutter - 访问颤振测试导致 tearDownAll
- c++ - 我无法通过它们的指针将多个类链接在一起
- java - 在两个对象上具有任何匹配的过滤流将一个对象的值设置为另一个对象的值