Error Gradle script ‘/home/runner/work/*/gradlew’ is not executable

Setting up Gradle CI build for Github Actions with the build action for Gradle https://github.com/gradle/gradle-build-action is straight forward after you have either initialize your Eclipse project with Gradle or added Gradle build support afterwards. This project is a Xtext project, but for the continuous integration (CI) it doesn’t matter since we are using Gradle build automation tool. Here’s the ci yaml file which is close to the template given.

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

permissions:
  contents: read

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        java-version: '11'
        distribution: 'temurin'
    - name: Build with Gradle
      uses: gradle/gradle-build-action@v2
      with:
        arguments: build

But we are hitting an error when trying to execute the Github Action pipeline. Error Gradle script /home/runner/work/*/gradlew is not executable.

This is a permission issue. To fix it we need to give it permission to execute the file by changing the file’s properties.

Solution 1 (preferred)

In VS code or command prompt run chmod command

git update-index --chmod=+x gradlew

Then check the changes in your source control and run your Github Action pipeline again.

Solution 2 (Alternative)

If you’re not able to change it for the source control for whatever reason, you can do it directly in the pipeline by adding an addition step

 - name: Run chmod to make gradlew executable
   run: chmod +x ./gradlew