Search code examples
javagradlegitlabgitlab-ciunzip

Can't find files downloaded inside gitlab runner


I'm setting up GitLab CI for a gradle project. After downloading gradle, the unzip command reports that no zip file is found even though the download was successful. I added a an ls just to see the contents of the directory and my zip file was not present. Below is my .gitlab-ci.yml file

image: docker:latest

stages:
  - build 

before_script:
  - cd /usr/lib
  - curl https://services.gradle.org/distributions/gradle-2.10-bin.zip -o gradle-2.10-bin.zip
  - unzip "gradle-2.10-bin.zip"
  - ln -s "/usr/gradle-2.10/bin/gradle" /usr/bin/gradle
  - rm "gradle-2.10-bin.zip"
  - export GRADLE_HOME=usr/lib/gradle-2.10
  - export PATH=$PATH:$GRADLE_HOME/bin

build_job:
  image: java:8
  stage: build
  script:
    - gradle -v

This the error output of the job

$ unzip "gradle-2.10-bin.zip" unzip: cannot find or open gradle-2.10-bin.zip, gradle-2.10-bin.zip.zip or gradle-2.10-bin.zip.ZIP. ERROR: Job failed: exit code 1


Solution

  • That is not the full error output of that command, this is:

    $ unzip "gradle-2.10-bin.zip"
    Archive:  gradle-2.10-bin.zip
      End-of-central-directory signature not found.  Either this file is not
      a zipfile, or it constitutes one disk of a multi-part archive.  In the
      latter case the central directory and zipfile comment will be found on
      the last disk(s) of this archive.
    unzip:  cannot find zipfile directory in one of gradle-2.10-bin.zip or
            gradle-2.10-bin.zip.zip, and cannot find gradle-2.10-bin.zip.ZIP, period.
    

    And if we check it that file is empty. If we do a curl -I on that url we get a 301 so you need to add the -L to that curl command to follow the redirection:

    curl -L https://services.gradle.org/distributions/gradle-2.10-bin.zip