【问题标题】:Continuously deploy two branches to two separate openshift applications on Travis CI?在 Travis CI 上持续将两个分支部署到两个单独的 openshift 应用程序?
【发布时间】:2015-09-10 22:14:29
【问题描述】:

我有一个 git repo,它有许多开发分支,还有一个名为 production 的分支用于生产,而 ma​​ster 用于暂存。

我想要实现的是,每当有人推送到 master 时,应用程序会被构建然后部署到临时应用程序,当有人推送到生产分支时,应用程序会被构建然后部署不同的生产应用程序。

我像这样配置了我的.travis.yml 文件:

sudo: false
language: node_js
node_js:
  - '0.10'
env:
  global:
  - GH_REF: github.com/AFusco/MyRepo.git
  - secure: (hidden)
install: "./scripts/install_dependencies.sh"
cache:
   directories:
    - node_modules
    - bower_components

deploy:
  provider: openshift
  skip_cleanup: true
  user: myname@gmail.com
  password:
    secure: (hidden)
  domain: correct_openshift_namespace
  app:
    master: staging
    production: production
after_success: 
  - ./scripts/deploy_app.sh

然而,在我的./script/deploy_app.sh

#!/bin/bash
set -ev

rm -rf ./dist
grunt build
cd ./dist
git init
git status
git config --global push.default simple
git config --global user.email "travis@travis-ci.com"
git config --global user.name "Travis CI"
git checkout -b master
git add --all
git commit -am "Travis deploy"

很遗憾,我收到了这个错误:

error: src refspec master does not match any.
error: failed to push some refs to 'ssh://45d0ca6189f5cfc35100010c@staging-mynamespace.rhcloud.com/~/git/staging.git/'

【问题讨论】:

    标签: git openshift travis-ci continuous-deployment


    【解决方案1】:

    我解决了这个问题,我觉得自己像个菜鸟。

    由于我提交了deploy_app.sh 脚本中的所有文件,因此脚本完成后我没有更改目录,因此dpl 脚本在根目录中启动,而不是在./dist 中启动

    我不得不将我的 .travis.yml 文件更改为:

    sudo: false
    language: node_js
    node_js:
      - '0.10'
    env:
      global:
      - GH_REF: github.com/AFusco/MyRepo.git
      - secure: (hidden)
    install: "./scripts/install_dependencies.sh"
    cache:
       directories:
        - node_modules
        - bower_components
    
    deploy:
      provider: openshift
      skip_cleanup: true
      user: myname@gmail.com
      password:
        secure: (hidden)
      domain: correct_openshift_namespace
      app:
        master: staging
        production: production
    after_success: 
      - ./scripts/deploy_app.sh
      - cd ./dist
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 2019-05-12
      • 2019-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      相关资源
      最近更新 更多