推动开发时防止BitBucket部署到heroku

时间:2017-12-01 02:43:39

标签: javascript git heroku bitbucket

我已经设置了bitbucket,通过设置bitbucket-pipelines.yml文件自动部署到Heroku。该文件的代码包含在下面。一切都很好。我每次部署时都会得到,Heroku会选择并成功构建。但是,它发生在两个分支上。我更喜欢只在主分支提交后构建。我认为这是可能的,但我发现的解决方案似乎无法发挥作用。

bitbucket-pipelines.yml文件:

image: node:6.9.4

  pipelines:
    default:
      - step:
          caches:
            - node
          script:
            - npm install
            - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD

我尝试过的解决方案:(会在我继续研究时更新)

  • 添加':refs / heads / master'背后' HEAD'在bitbucket.pipelines.yml的最后一行

编辑: 根据VonC的建议,我将我的bitbucket-pipelines.yml文件更改为下面的代码,它可以工作!非常感谢你的帮助。

image: node:6.9.4

  pipelines:
    branches:
      master:
        - step:
            caches:
              - node
            script:
              - npm install
              - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD

1 个答案:

答案 0 :(得分:1)

这应该是" Branch workflows"描述:

image: node:5.11.0
pipelines:
  default:
    - step:
        script:
          - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
  branches:
    master:
      - step:
          script:
            - echo "This script runs only on commit to the master branch."
    feature/*:
      - step:
          image: java:openjdk-9 # This step uses its own image
          script:
            - echo "This script runs only on commit to branches with names that match the feature/* pattern."