An example showing how to run a Cloud Foundry Task using Travis CI.
.travis.yml
- the Travis config file that builds and runs a Docker image to run the taskDockerfile
- used to create the image that hascf cli
tools to run the taskentrypoint.sh
- script that authenticates with cloud.gov and runs the taskindex.js
andpackage.json
- these are just dummy app files that are used to kick off a build in Travis CI. They are deliberately simple and bare-bones.
First, set up a cloud.gov service account and generate credentials.
Store the values for CF_USERNAME
, CF_PASSWORD
(which are generated in the previous step), CF_ORG
, and CF_SPACE
as environmental variables in Travis.
The docker run
command in the .travis.yml
file passes variables to the entrypoint.sh
file in the Docker container. Change the placeholders with the following values:
your-app-name
- the app that you want to run a task on (note, this can be any app in your org/space)your-task
- the task you want to runyour-task-name
- the name of the task
The task you run could be a command (e.g., "rails app:sessions:sweep"), or you could invoke a script (e.g., "./my-task.sh") that has been deployed as part of the app you want to run the task on. The choice is yours.
To set your task to run at specified intervals, you can use the cron feature of Travis.