Travis offers a deployment configuration which fortunately supports OpenShift, the following steps shows how to get it working.
The command line client has been used to secure our OpenShift token.
First of all we need to install the CLI following its documentation,
but basically if we already have ruby
installed in our system we
just need to install the following gem:
gem install travis
Travis must be integrated in GitHub which can be done in a few steps:
Save the token given by the Login command.
In the upper right corner click on your name then Settings and again
the Settings tab as shown in the screenshot, then finally click in
Copy token
.
travis login --github-token {{TOKEN}} --com
Replace {{TOKEN}}
with the real token copied in the step 2.
First add an environment variable in Travis:
travis env set OPENSHIFT_TOKEN {{TOKEN}} --com
Then add the encrypted value in our .travis.yml
file:
travis encrypt --add deploy.token {{TOKEN}}
Replace {{TOKEN}}
with the real token copied in the step 1.
.travis.yml
The following excerpt shows only the deploy stage, the full configuration file can be found here.
- stage: deploy
name: Deploy to OpenShift
script: skip
deploy:
provider: openshift
server: https://api.us-east-2.starter.openshift-online.com:6443
project: workday
app: api
edge: true
on:
branch: master
token:
secure: dQ/DwmYDyJ2JkhUh++II/1QgnIU/TAlobn//zki+G/Id9+Z4XU0DwGHb+WQuxS+RBqASS79imBkzd0b8uZsSgzf8mEFCEbzikZy3rYGJW/CVFVKygbOBRsM7ms+clAEAr9cet6QqKBeRt6WH3AiPfetcNw0GpjKYr0WGdzzq+sf347NRFrhr/rSiOeugBq2EYqtuXeE6tAzm0ivGLl9C4hDYBdkYiQfJ16hk+/hJrwFRZpVv+7yR9J+WphMVqbCrB0XY3qSnwUlgfMw5QdCFvZAqoZbbiIF0OqEDZ+kwSVSPKPZ/zybpyrE+ty83GGuQ3MymMLM35Upr51HB6VNAcwtpwW8Cf3Bzj2odFKzk26etvUDhaPpXMV8Ow9VgYgweEti9KebdM0esN5emr/7vCmLVe3ppNDhH+tfGGmaVM8dkB+L4d2A4kXoxfHyS59HZPGBVFPLmNrxgwxbVaO7EiqUPlBX7SOMMNKn83HUF96edCOXwqVdznfLaG9Uh1/pvfTj4N1NOO1zTdTuuda4WeXSAyWEpgc15RwNQcYp6smtgXk3zFYKA0ZB9C9jyO01Fvoy96H8llY+wrEVuiUmyzSu3KAk6+86SLPJQUHWsvhSTES7qb6c5oSmoBao7X97b4/3EOGHq86wJLE/6vjrqWlrq3BtXpXqiOcbB5el1a9M=
server
parameter must be set accordingly with your OpenShift
endpoint.project
and app
parameters must match the ones provided in
the deployment commands.edge
parameter tells Travis to use the deployment version 2
which is currently in beta (but still recommended by Travis here).script: skip
parameter tells Travis to don’t run any build
command (we don’t have to waste time here).on: branch
parameter tells Travis to only deploy when
there are changes in the master branch.