joesan
joesan

Reputation: 15435

Travis CI Timeout For Specific Jobs

I have a Travis CI based build and I have several jobs where one of them is supposed to push an image to a remote docker registry. Now at times this registry could not be available and in those situations, I would like to timeout this specific job, say after 10 minutes!

So here is what I have now:

jobs:
  include:
    - stage: test
      script: sbt clean coverage test coverageReport
    - stage: build docker image
      script:
        - if [ $TRAVIS_BRANCH == "master" ]; then
            sbt docker:publishLocal;
            docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD $DOCKER_REGISTRY_URL;
            docker push $APPLICATION_NAME:$IMAGE_VERSION_DEV;
          fi

I can see from the build logs that the build times out after 10 minutes which seems to be the default. But how do I override and set it to 5 minutes?

I could not find enough reference on the Travis CI website. How could I now add a Timeout to the build docker stage above?

Any suggestions?

Upvotes: 1

Views: 1010

Answers (2)

Hedgehog
Hedgehog

Reputation: 5657

There are several options/ideas you can explore when using travis_wait:

  1. Export the travis_wait function and use it within your bash scripts

    scripts:
     - export -f travis_wait
     - cat./scripts/yours-using-travis_wait.sh | sudo bash -s $SOME_VAR
    
  2. Use travis_wait directly in the travis-ci script step

    scripts:
     - travis_wait 90 make install
       # OR
     - travis_wait 90 sleep infinity & 
     - cat./scripts/yours.sh | sudo bash -s $SOME_VAR
       # OR in some cases this "quoting" has worked
     - "travis_wait 90 sleep infinity&"
     - curl --funky-stuff-here
    

Upvotes: 1

Dominic Jodoin
Dominic Jodoin

Reputation: 2538

You can use the travis_wait Bash function to achieve what you want e.g.

travis_wait 5 docker push $APPLICATION_NAME:$IMAGE_VERSION_DEV;

See https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

Upvotes: 2

Related Questions