0

In my project I use Travis-CI for continuous integration (builds on every MR to master branch) and also for deploying the artifact to Heroku. Here is my .travis.yml file:

language: java
jdk: oraclejdk8

branches:
  only:
    - master

script:
  mvn package

deploy:
  provider: heroku
  api_key: $HEROKU_API_KEY

notifications:
  email:
    on_success: never
    on_failure: always

And here is my Procfile:

web java -Dserver.port=$PORT -jar target/my-artifact.jar

Here you can see that I use PORT Heroku variable, but I also use few custom variables. Sometimes I need to update their values after new build. Previously I did it manually, but I'm looking how I can automate this. I need to update Heroku environment variables with values which I determine in time of Travis-CI build. How can I do that?

Hleb
  • 7,037
  • 12
  • 58
  • 117

1 Answers1

2

You can set your environment variables using the Heroku platform API: https://devcenter.heroku.com/articles/platform-api-reference#config-vars

In Travis, you can run a task pre-deploy using the 'before_deploy' step (https://docs.travis-ci.com/user/customizing-the-build#The-Build-Lifecycle)

So create a script that uses the Heroku platform API to update your environment and run it as part of your before_deploy step.