Travis-CI:将不同的分支部署到不同的服务器

时间:2016-09-15 08:17:22

标签: git deployment continuous-integration travis-ci cloudfoundry

目前,我正在尝试使用github repo和Travis-CI为持续集成设置一个概念项目。

My.travis.yml看起来像这样

language: java
jdk:
- oraclejdk8
before_cache:
- rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
branches:
 only:
 - master
 - develop

deploy:
 provider: cloudfoundry
 api: https://api.eu-gb.bluemix.net
 username: j.cuppen@acuity.nl
 password:
  secure: [key]
 organization: 'Acuity\ Stagiairs'
 space: 'stage\ job'
 on:
  repo: JasonLighthunter/GradleTest
  branch: develop

我的manifest.yml看起来像这样:

---
applications:
- name: gradleweb
  memory: 512M
  host: gradleTest
  path: build/libs/GradleTest.war

目前,当我推动开发构建并部署到gradleTest.eu-gb.mybluemix.net

我试图找出的是如何配置travis的方式,当主人被推送时,它被部署到,比方说:gradleProd.eu-gb.mybluemix.net

提前致谢

1 个答案:

答案 0 :(得分:1)

您可以为每个部署指定manifest个文件。将您的.travis.yml更改为:

deploy:
  - provider: cloudfoundry
    edge: true
    username: ${CF_USERNAME}
    password: ${CF_PASSWORD}
    organization: ${CF_ORGANIZATION}
    space: ${CF_SPACE}
    api: https://api.ng.bluemix.net/
    manifest: manifest.master.yml
    on:
      branch: master
  - provider: cloudfoundry
    edge: true
    username: ${CF_USERNAME}
    password: ${CF_PASSWORD}
    organization: ${CF_ORGANIZATION}
    space: ${CF_SPACE}
    api: https://api.ng.bluemix.net/
    manifest: manifest.develop.yml
    on:
      branch: develop

在这种情况下,您可以添加两个文件:manifest.develop.ymlmanifest.master.yml