我有一个Im正在进行的项目的bitbucket管道yaml文件。将其设置为在push上运行时,我可以很好地运行管道,但是由于我将其切换为在pull-request上运行,所以我收到了无效的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
答案 0 :(得分:0)
原来,我认为这只是评论,在仔细检查后是文件的必要部分。只需确保正确缩进(空格)即可。
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