我想对不同的构建类型使用 github 操作矩阵,但我对支持该矩阵的一种情况不感兴趣。如何阻止此案例运行,但仍能成功标记构建。
在这种特殊情况下,我想构建 Windows 和 Ubuntu、32 位和 64 位,但我对在 Ubuntu 上支持 32 位不感兴趣。所以我的矩阵是:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
platform: ['x64', 'x86']
Run Code Online (Sandbox Code Playgroud)
我当前的解决方案是通过添加 if 表达式来停止每个操作的运行:
- name: Build Native
if: ${{ ! (matrix.os == 'ubuntu-18.04' && matrix.platform == 'x86') }}
Run Code Online (Sandbox Code Playgroud)
虽然这工作正常,但我觉得应该有一种更优雅的方法来解决这个问题。谁能帮我让我的 yaml 脚本更漂亮吗?
因此,最近我开始着手将 Azure Devops Classic Release 管道迁移到基于 YAML 的管道。
我正在努力重现的是经典发布管道能够使用下拉列表从关联的构建管道中选择特定工件的能力。
我发现允许用户指定特定工件的唯一方法是通过参数,但只有当您知道列表中的所有值时,才可以定义下拉列表。
此链接是我发现的最接近解决问题的链接,但即使这样也不允许指定下拉列表: https://www.huuhka.net/runtime-artifact-selection-in-azure-pipelines- yaml/
有人知道如何做到这一点,或者即使有可能吗?
我有以下 YAML
version: "0.1"
services:
svc:
image: test
networks:
- test_net_1
- test_net_2
- test_net_3
networkMapping:
test_net_1:
external: true
test_net_2:
external: true
test_net_3:
external: true
Run Code Online (Sandbox Code Playgroud)
我想networkMapping
在一行中重写该值,如下所示:
version: "0.2"
services:
svc:
image: test
networks: ['test_net_1', 'test_net_2', 'test_net_3']
networkMapping: {{'test_net_1': {'external': true}}, {'test_net_2': {'external': true}}, {'test_net_3': {'external': true}}}
Run Code Online (Sandbox Code Playgroud)
但是当 linting / 解析它时,它返回:
version: "0.2"
services:
svc:
image: test
networks:
- test_net_1
- test_net_2
- test_net_3
networkMapping:
?
test_net_1':
external: true
: ~
?
test_net_2:
external: true
: ~
?
test_net_3: …
Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的 yaml 文件:
apiVersion: v1
entries:
blue-green-toggle:
- description: Used to toggle an application between blue and green
name: blue-green-toggle
version: 1.0.17
apiVersion: v2
- description: Used to toggle an application between blue and green
name: blue-green-toggle
version: 1.0.16
apiVersion: v2
- description: Used to toggle an application between blue and green
name: blue-green-toggle
version: 1.0.15
apiVersion: v2
istio-config:
- description: Used to configure the cluster level settings of istio.
name: istio-config
version: 1.0.4
apiVersion: v2
- description: Used to …
Run Code Online (Sandbox Code Playgroud) 我有以下yaml
文件:
trainingPhrases:
- help me
- what to do
- how to play
- help
Run Code Online (Sandbox Code Playgroud)
我使用 from node 从磁盘读取它并使用fromreadFile
解析它:load
js-yaml
import { load } from "js-yaml";
import { readFile } from "fs/promises";
const phrases = load(await readFile(filepath, "utf8")).trainingPhrases as string[];
Run Code Online (Sandbox Code Playgroud)
我收到以下eslint
警告:
ESLint: Unsafe member access .trainingPhrases on an any value.(@typescript-eslint/no-unsafe-member-access)
Run Code Online (Sandbox Code Playgroud)
我不想抑制警告,而是想将其映射到 YAML 文件的具体类型(例如在 axios 中发生的情况:axios.get<MyResponseInterface>(...)
- 执行 aGET
并MyResponseInterface
定义 HTTP 响应的结构)。
有专门的图书馆吗?
我觉得我已经尝试了几乎所有的组合来使其发挥作用,但却空手而归。有人这样做过吗?我试图在引用参数 ApiStack 时引用子内部的导入值。感谢任何建议!
LambdaPermission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName: !GetAtt MyLambdaFunction.Arn
Principal: apigateway.amazonaws.com
SourceArn: !Sub
- arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGateway}/*/POST/CreateBofAParameter
- ApiGateway: !ImportValue
'Fn::Sub': '${ApiStack}--APIID'
Run Code Online (Sandbox Code Playgroud) 我已在名为“DevOps”的单独存储库中添加了 .Net CI CD 管道的 yaml 模板。每个 .Net 服务管道都从“DevOps”调用此 yaml 模板。
在 DevOps 中,我有两个分支 - 一个是主分支,一个是 beta 分支。
.Net 服务管道中源/开发分支的所有触发器都应使用“DevOps”测试分支中的模板。.Net 服务管道中主分支的管道触发器应使用 main 中的模板。-这是要求。
我使用了正则表达式/if条件/语法,使用了when/if,所有这些要么抛出表达式/条件错误,要么只是从main中获取模板。下面是我所做的各种尝试的屏幕截图(较旧的已评论)。
有没有办法在存储库语法中实现条件?
更新:我已经根据 Kotaro 的解决方案更新了管道,如下所示。我希望可以在资源语法中添加变量
但这是我尝试运行管道时得到的结果:
我的 GitLab 中运行着一个 CI 作业列表,但缓存未按预期工作:
这就是我的文档生成工作的结束方式:
[09:19:33] Documentation generated in ./documentation/ in 4.397 seconds using gitbook theme
Creating cache angular...
00:02
WARNING: frontend/node_modules: no matching files
frontend/documentation: found 136 matching files
No URL provided, cache will be not uploaded to shared cache server. Cache will be stored only locally.
Created cache
Job succeeded
Run Code Online (Sandbox Code Playgroud)
然后我开始部署作业(到 GitLab Pages),但它失败了,因为它找不到文档文件夹:
$ cp -r frontend/documentation .public/frontend
cp: cannot stat 'frontend/documentation': No such file or directory
Run Code Online (Sandbox Code Playgroud)
这是这一代的缓存配置:
generate_docu_frontend:
image: node:12.19.0
stage: build
cache:
key: angular
paths: …
Run Code Online (Sandbox Code Playgroud) 我的工作内容如下.gitlab-ci.yml
:
stages:
- stage1
- stage2
job1:
stage: stage1
script:
- echo "Running default stage1, pipeline_source=$CI_PIPELINE_SOURCE"
job2:
stage: stage2
rules:
- if: $CI_PIPELINE_SOURCE == "push"
- when: always
script:
- echo "Running STAGE2! pipeline_source=$CI_PIPELINE_SOURCE"
Run Code Online (Sandbox Code Playgroud)
当我将此更改提交到合并请求分支时,似乎正在启动两个管道。
这是 gitlab 中的已知问题吗?或者我在这里理解有问题?
yaml ×10
azure ×2
azure-devops ×2
gitlab ×2
gitlab-ci ×2
javascript ×1
mapping ×1
pipeline ×1
release ×1
types ×1
typescript ×1
yq ×1