简体   繁体   English

bitbucket 管道 - InBuilt 变量打印空值

[英]bitbucket pipeline - InBuilt variable prints empty value

I am trying to implement python static analysis for one of my project.我正在尝试为我的一个项目实施 python static 分析。 However, I want to do this only on difference of file rather than all the files.但是,我只想对文件的差异而不是所有文件执行此操作。 The reason being we have lots of file already committed which has issue and it's not feasible to fix it in time.原因是我们已经提交了很多有问题的文件,无法及时修复。

I am trying to use following code, but it's failing.我正在尝试使用以下代码,但它失败了。

pipelines:
  default:
       - step:
          name: python_static_analysis
          image: python:3.7.3
          script:
            - pip install flake8
            - echo $BITBUCKET_BRANCH
            - echo $BITBUCKET_PR_DESTINATION_BRANCH
            - git diff -u -relative origin/$BITBUCKET_BRANCH origin/$BITBUCKET_PR_DESTINATION_BRANCH --name-only -- '*.py'
            #- flake8 $(git diff -u -relative origin/$BITBUCKET_BRANCH origin/$BITBUCKET_PR_DESTINATION_BRANCH --name-only -- '*.py')

this is the errror这是错误

在此处输入图像描述

BITBUCKET_PR_DESTINATION_BRANCH variable comes out as empty, not sure why? BITBUCKET_PR_DESTINATION_BRANCH变量显示为空,不知道为什么?

As the documentations says https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/#Default-variables the BITBUCKET_PR_DESTINATION_BRANCH variable is正如文档所说https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/#Default-variables BITBUCKET_PR_DESTINATION_BRANCH变量是

Only available on a pull request triggered build .仅在拉取请求触发构建时可用

So the problem is that you defined this step as part of a default pipeline whereas you should have written所以问题是您将此步骤定义为默认管道的一部分,而您应该编写

pipelines:
  pull-requests:
    '**':
      - step:
          # ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM