The Holy Java

Building the right thing, building it right, fast

How to patch Travis CI’s deployment tool for your needs

Posted by Jakub Holý on January 9, 2018

Travis CI is a pretty good software-as-a-service Continuous Integration server. It can deploy to many targets, including AWS BeanStalk, S3, and CodeDeploy.

However it might happen that the deploy tool (dpl) has a missing feature or doesn’t do exactly what you need. Fortunately it is easy to fix and run a modified version of the tool, and I will show you how to do that.

My particular problem is that dpl allows me to upload an archive to S3 and to create a CodeDeploy deployment, but it lacks the intermediary and required step of registering a new revision based on the uploaded archive. (See #732)

To fix this:

  1. Subclass and fix the deployer
  2. Send a pull request to Travis CI 🙂
  3. Run it as a Ruby script

Here is an example of fixing the code_deploy.rb to fetch S3 version and etag and register a revision before proceeding with creating the deployment:

As shown in the code, you can run it from the command line. To run it from your Travis CI build:

# excerpt from .travis.yml
  - provider: s3
    local_dir: dpl_cd_upload
    skip_cleanup: true
    bucket: my-bucket 
    region: eu-west-1
  - provider: script
    script: ruby ./deploy_codedeploy.rb


PS: Or you can fork dpl and use your forked one, as described in Testing dpl in the context of Travis CI builds. This builds the whole dpl gem on the build VM.

Sorry, the comment form is closed at this time.

%d bloggers like this: