Build started failing for reasons unknown

My travis builds used to work just fine until today, since when they’ve been failing consistently, even though I didn’t tamper the .travis.yml file in my recent commits. The part where my builds fail is when executing the following code block:

if [ $latest ]; then
      link=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "/hugo_[0-9]\.[0-9]*_Linux-64bit.tar.gz" | cut -d\" -f4)
    else 
      link="https://github.com/gohugoio/hugo/releases/download/v${minVer}/hugo_${minVer}_Linux-64bit.tar.gz"
    fi

For some reason, the $link variable doesn’t get initialised which causes the build to fails later on.

Have any considerable changes been made to travis which are causing these failures or is the issue arising just from my side?

Here’s my .travis.yml: hugo-dream-plus/.travis.yml
Here’s my build log: The build log

My guess is that your API call to GitHub is failing because of rate limiting. (All of Travis CI builds share the same pool of IP addresses, so unauthenticated API requests are subject to 60 requests per hour.)

If this is critical to you, you should add your own GitHub token to ensure that you get a more reliable result.

Incidentally, if [ $latest ]; then …; fi does not work the way you seem to be expecting when you set latest=false. if [ $latest ]; simply means that $latest has a nonzero string, which is true when you set latest=false. (Recall that all Bash variables are strings; it does not have any idea of Booleans, for example.) You probably want something like if [ $latest != 'false' ]; then ….

1 Like

Thanks for pointing out my code errors, it seems that I had tested it on zsh. Also, I’ve now increased my rate-limit by adding a token and that worked for me.