gradle/gradle-build-action

Unable to use gradle wrapper

matej-staron opened this issue · 1 comments

Hello, I am not able to run any of the workflow examples using ./gradlew.
It seems that the wrapper script is not created anywhere on the runner. Any idea what might be causing this?

Example workflow:

name: Print gradle version
on: workflow_dispatch
jobs:
  gradle:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-java@v4
      with:
        distribution: temurin
        java-version: 11
        
    - name: Setup Gradle
      uses: gradle/gradle-build-action@v2
    
    - name: Check gradle version
      run: ./gradlew --version

The last step simply fails with the following:

Run ./gradlew --version
  ./gradlew --version
  shell: /usr/bin/bash -e {0}
  env:
    JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.21-9/x64
    JAVA_HOME_11_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.21-9/x64
    GRADLE_BUILD_ACTION_SETUP_COMPLETED: true
    GRADLE_BUILD_ACTION_CACHE_RESTORED: true
/home/runner/work/_temp/4819faeb-ded6-4dde-b4c0-b2da96366740.sh: line 1: ./gradlew: No such file or directory
Error: Process completed with exit code 127.

Any help is appreciated!

bigdaz commented

The Gradle Wrapper works by having a gradlew file committed to your repository. It won't be created by the gradle-build-action and doesn't exist on the runner.

Your options are:

  1. Add the Gradle Wrapper and commit the files to your project as described here.
  2. Don't use the Gradle Wrapper, and ask the gradle-build-action to install the required version.

For the latter, your workflow will look something like this:

    - name: Setup Gradle
      uses: gradle/gradle-build-action@v2
      with:
        gradle-version: 8.5
    
    - name: Check gradle version
      run: gradle --version