gpt4 book ai didi

continuous-integration - 为什么我的 bitbucket-pipelines.yml 对拉取请求脚本无效

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

我有一个用于我正在处理的项目的 bitbucket 管道 yaml 文件。当它被设置为在推送时运行时,我让它运行良好,但由于我将它切换为在拉取请求时运行,我得到了一个无效的 yml 错误。

我找到了关于如何配置文件的说明:https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html

validator ,我在第一步收到一个错误,提示 Expected a string but found a mapping

当我通过拉取请求运行它时,出现以下错误:

Configuration error
There is an error in your bitbucket-pipelines.yml at [pipelines > pull-requests].
To be precise: This section should be a map (it is currently defined as a list).

我不确定如何修复它,因为它似乎与示例相符。

下面是我的yml文件

image: node:8.10
pipelines:
pull-requests:
- step:
name: Push repo to CodeCommit
script:
- echo $CodeCommitKey > ~/.ssh/codecommit_rsa.tmp
- base64 -di ~/.ssh/codecommit_rsa.tmp > ~/.ssh/codecommit_rsa
- chmod 400 ~/.ssh/codecommit_rsa
- echo $CodeCommitConfig > ~/.ssh/config.tmp
- base64 -di ~/.ssh/config.tmp > ~/.ssh/config
- set +e
- ssh -o StrictHostKeyChecking=no $CodeCommitHost
- set -e
- git remote add codecommit ssh://$CodeCommitRepo
- git push codecommit $BITBUCKET_BRANCH
- step:
name: Test and Build
caches:
- node
script:
- npm install --no-package-lock
- npm run test
- step:
name: Deploy Serverless
script:
- npm i serverless -g
- npm run deploy

最佳答案

原来我以为只是注释,仔细检查是文件的必要部分。只需确保正确缩进(空格)即可。

image: node:8.10
pipelines:
pull-requests:
'**':
- step:
name: Push repo to CodeCommit
script:
- echo $CodeCommitKey > ~/.ssh/codecommit_rsa.tmp
- base64 -di ~/.ssh/codecommit_rsa.tmp > ~/.ssh/codecommit_rsa
- chmod 400 ~/.ssh/codecommit_rsa
- echo $CodeCommitConfig > ~/.ssh/config.tmp
- base64 -di ~/.ssh/config.tmp > ~/.ssh/config
- set +e
- ssh -o StrictHostKeyChecking=no $CodeCommitHost
- set -e
- git remote add codecommit ssh://$CodeCommitRepo
- git push codecommit $BITBUCKET_BRANCH
- step:
name: Test and Build
caches:
- node
script:
- npm install --no-package-lock
- npm run test
- step:
name: Deploy Serverless
script:
- npm i serverless -g
- npm run deploy

关于continuous-integration - 为什么我的 bitbucket-pipelines.yml 对拉取请求脚本无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56155108/

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