Sam
Sam

Reputation: 1304

Update gradle version in a gitlab-ci build

I've built a gitlab-ci yaml file, which works well. However the gradle version used in the image is different to that on my local machine. This is causing some unusual side effects, such as only some Java tests being run.

Here's my yaml file:

image: java:8-jdk
before_script:
  - echo `pwd`
  - export GRADLE_USER_HOME=`pwd`/.gradle
  - rm -f  .gradle/caches/modules-2/modules-2.lock
  - rm -fr .gradle/caches/*/plugin-resolution/
cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches
build:
  script:
    - ./gradlew build

test:
  stage: test
  script:
    - ./gradlew test
    - cat build/jacocoHtml/index.html | grep -o 'Total[^%]*%'
  artifacts:
    paths:
      - build/jacocoHtml

      #deploy test coverage
pages:
  stage: deploy
  dependencies:
    - test
  script:
    - mkdir public
    - mkdir public/jacoco
    - mv build/jacocoHtml/* public
  artifacts:
    paths:
      - public
  only:
    - master

Currently, the build is being run on 4.10.3 but I need to update this to 5.1.1 to match my local setup.

Thanks in advance,

Sam

Upvotes: 0

Views: 4058

Answers (1)

Nicolas Pepinster
Nicolas Pepinster

Reputation: 6221

Use gradle docker image instead of java:8-jdk

For the version 5.1.1 with jdk8, use :

image: gradle:5.1.1-jdk8

Upvotes: 4

Related Questions