Job Cuppen Job Cuppen - 9 days ago 6
Git Question

Travis-CI: deploy different branches to different servers

Currently I'm trying to setup a concept project for Continuous Integration using a github repo in combination with Travis-CI.

My.travis.yml looks like this

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


and my manifest.yml looks like this:

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


Currently when i push to develop it builds and deploys to gradleTest.eu-gb.mybluemix.net

What im trying to figure out is how I can configure travis in such a way that when the master is pushed it is deployed to, let's say: gradleProd.eu-gb.mybluemix.net

Thanks in advance

Answer

You can use specify manifest file for each deploy. Change your .travis.yml to:

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

in this case you can add two files: manifest.develop.yml and manifest.master.yml

Comments