【问题标题】:Specify the git branch code to be deployed in Elastic Beanstalk environment指定要在 Elastic Beanstalk 环境中部署的 git 分支代码
【发布时间】:2016-11-09 15:26:52
【问题描述】:

有没有办法指定将哪个 git 分支代码部署到 Elastic Beanstalk 环境?

假设,我有两个名为 teststage 的 git 分支,并且我有一个名为 test-env 的 Elastic Beanstalk 环境。

现在,我将config.yml 中的分支默认设置如下:

branch-defaults: 
  test:
    environment: test-env
    group_suffix: null
global:
  application_name: test
  default_ec2_keyname: abcde
  default_platform: Ruby 2.2 (Puma)
  default_region: us-west-2
  profile: eb-cli
  sc: git

现在,我需要的是,如果我使用 eb deploy test-envstage 分支部署它应该自动从 test 分支部署代码,否则它应该会抛出错误。

有什么办法吗。如果没有,请建议我采取其他方法。

谢谢..

【问题讨论】:

    标签: ruby-on-rails git amazon-web-services amazon-elastic-beanstalk


    【解决方案1】:

    这不是 EB CLI 支持的;它将始终从当前分支运行部署。但是,这当然是您可以编写脚本的东西(我假设您在bash 下运行,使用for 命令提取当前分支名称来移植到Windows 命令shell 不会太难): 部署测试.sh:

    #!bin/bash
    # Grab the current branch name
    current=`git rev-parse --abbrev-ref HEAD`
    # Just in case we have any in-flight work, stash it
    git stash
    # Switch to 'test' branch
    git checkout test
    # Deploy to  test-env
    eb deploy test-env
    # Switch back to whatever branchwe were on
    git checkout $current
    # Restore in-flight work
    git stash pop
    

    【讨论】:

      猜你喜欢
      • 2016-04-20
      • 2015-10-23
      • 2016-07-18
      • 1970-01-01
      • 2020-05-29
      • 2015-08-10
      • 2016-06-07
      • 2021-06-28
      • 2017-10-12
      相关资源
      最近更新 更多