每天的自动bitbucket用手动步骤部署到分支

发布于 2025-01-23 20:44:00 字数 1202 浏览 1 评论 0原文

我试图在Bitbucket中设置一条管道,其中有两个分支的日程安排。

开发:计划每日部署 +当我推到该分支时,管道再次运行

:这是棘手的。我想每天部署,因为需要每天重建页面,但是我想拥有一个安全性的,如果有人错误地推到该分支机构,或者代码不好,则只能在手动触发后运行部署。

所以我的问题是,可以设置一个规则以跟踪是否有推动力,在这种情况下,让管理员手动启动管道?


pipelines:
  branches:
    develop:
      - step:
          name: Deploy staging
          deployment: staging
          caches:
            - node
          script:
            - npm run staging:auto
            - npm install firebase
            - npm install firebase-functions
            - npm install -g firebase-tools
            - firebase deploy --token=$FIREBASE_TOKEN --project $FIREBASE_PROJECT_STAGING --only functions,hosting
          artifacts:
            - build/**
    master:
      - step:
          name: Deploy to production
          deployment: production
          caches:
            - node
          script:
            - npm run deploy:auto
            - npm install firebase
            - npm install firebase-functions
            - npm install -g firebase-tools
            - firebase deploy --token=$FIREBASE_TOKEN_STAGING --project $FIREBASE_PROJECT_PRODUCTION --only functions,hosting
          artifacts:
            - build/** ```

I'm trying to set up a pipeline in Bitbucket with a daily schedule for two branches.

develop : There a scheduled daily deployment running + when I push to this branch the pipeline runs again

master : This is the tricky one. I want to have a daily deployment because the page need to be rebuild daily, but I would like to have a security that if anyone pushes to this branch by mistake or the code is bad, it only runs the deployment after a manual trigger.

So my question is that is it possible to set up a rule to track if there was a push and in this case let the admin manually start the pipeline ?


pipelines:
  branches:
    develop:
      - step:
          name: Deploy staging
          deployment: staging
          caches:
            - node
          script:
            - npm run staging:auto
            - npm install firebase
            - npm install firebase-functions
            - npm install -g firebase-tools
            - firebase deploy --token=$FIREBASE_TOKEN --project $FIREBASE_PROJECT_STAGING --only functions,hosting
          artifacts:
            - build/**
    master:
      - step:
          name: Deploy to production
          deployment: production
          caches:
            - node
          script:
            - npm run deploy:auto
            - npm install firebase
            - npm install firebase-functions
            - npm install -g firebase-tools
            - firebase deploy --token=$FIREBASE_TOKEN_STAGING --project $FIREBASE_PROJECT_PRODUCTION --only functions,hosting
          artifacts:
            - build/** ```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2025-01-30 20:44:00

我建议除了推到生产分支机构的那一条自定义管道。可以使用YAML锚点重复使用相同的步骤定义,您可以在其中一个中替换触发

例如:

definitions:

  # write whatever is meaningful to you,
  # just avoid "caches" or "services" or
  # anything bitbucket-pipelines could expect
  yaml-anchors:

    - &deploy-pro-step
        name: Deploy production
        trigger: manual
        deployment: production
        script:
          - do your thing

pipelines:

  custom:

    deploy-pro-scheduled:
      - step:
          <<: *deploy-pro-step
          trigger: automatic

  branches:

    release/production:
      - step: *deploy-pro-step

对不起,如果我犯了一些yaml错误,但这应该是一般的想法。设置时间表时,在Web界面中配置了计划自定义管道的分支。

I'd suggest to schedule a different custom pipeline other than the one that runs on pushes to the production branch. The same steps definition can be reused with a yaml anchor and you can replace the trigger in one of them.

E.g:

definitions:

  # write whatever is meaningful to you,
  # just avoid "caches" or "services" or
  # anything bitbucket-pipelines could expect
  yaml-anchors:

    - &deploy-pro-step
        name: Deploy production
        trigger: manual
        deployment: production
        script:
          - do your thing

pipelines:

  custom:

    deploy-pro-scheduled:
      - step:
          <<: *deploy-pro-step
          trigger: automatic

  branches:

    release/production:
      - step: *deploy-pro-step

Sorry if I make some yaml mistakes, but this should be the general idea. The branch where the scheduled custom pipeline will run is configured in the web interface when the schedule is set up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文