ard*_*dev 5 continuous-integration bitbucket bitbucket-pipelines
我有一个用于我正在处理的项目的 bitbucket pipeline yaml 文件。当它设置为在推送上运行时,我让它运行良好,但由于我将其切换为在拉取请求上运行,我收到了无效的 yml 错误。
我找到了如何配置文件的描述:https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
在验证器中,我在第一步收到一个错误,提示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).
Run Code Online (Sandbox Code Playgroud)
我不确定如何修复它,因为它似乎与示例相匹配。
下面是我的 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
Run Code Online (Sandbox Code Playgroud)
原来我以为只是一条评论,仔细一看却是文件的必要组成部分。只要确保正确缩进(空格)即可。
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
Run Code Online (Sandbox Code Playgroud)