gpt4 book ai didi

azure-devops - 在 Azure DevOps 构建管道期间创建 json 文件

转载 作者:行者123 更新时间:2023-12-04 07:20:25 25 4
gpt4 key购买 nike

我有一个运行 Cypress 测试的 Azure DevOps 构建管道。在那个 Cypress 测试中,我们有一个使用电子邮件和密码登录的测试用户。在我的本地系统上,我的密码在 cypress.env.json 中。文件。
在 Azure 构建管道上,我收到密码为 undefined 的消息。这是有道理的,因为我们把 cypress.env.json .gitignore 中的文件不要将其暴露给 repo。
我创建了一个 Azure 变量来表示密码:$(ACCOUNT_PASSWORD)所以我想我需要创建 cypress.env.json生成管道中的文件并为其使用 Azure 变量,但我不知道如何在生成步骤中创建文件。
我有这个任务:

- task: CmdLine@2
displayName: 'run Cypress'
inputs:
script: |
npm run ci
所以我需要在这之前添加一个任务来创建 cypress.env.json带有代表密码的变量的文件:
{
"ACCOUNT_PASSWORD": $(ACCOUNT_PASSWORD)
}

最佳答案

您可以添加一个简单的 PS 脚本来创建文件:

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$json = '{
"ACCOUNT_PASSWORD": $(ACCOUNT_PASSWORD)
}'

$json | Out-File cypress.env.json
workingDirectory: '$(Build.SourcesDirecory)'
pwsh: true # For Linux
workingDirectory设置您希望创建文件的路径。

关于azure-devops - 在 Azure DevOps 构建管道期间创建 json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68542830/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com