加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 指定要在Elastic Beanstalk环境中部署的git分

发布时间:2020-12-17 02:25:55 所属栏目:百科 来源:网络整理
导读:有没有办法指定要部署到Elastic Beanstalk环境的git分支代码? 假设,我有两个名为test和stage的git分支,我有一个名为test-env的Elastic Beanstalk环境. 现在,我在config.yml中设置分支默认值如下: branch-defaults: test: environment: test-env group_suff
有没有办法指定要部署到Elastic Beanstalk环境的git分支代码?

假设,我有两个名为test和stage的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-env从stage分支部署,它应该自动从测试分支部署代码,否则它应该抛出错误.

有没有办法做到这一点.如果没有请建议我一些其他方式来做它..

谢谢..

解决方法

这不是EB CLI支持的内容;它将始终从当前分支运行部署.但是,它肯定是你可以编写的脚本(我假设你在bash下运行,使用for命令提取当前分支名称移植到Windows命令shell并不太难):

deployTest.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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读