개발/Git

[Github Actions] Error: Gradle script is not executable 오류 해결

선우. 2022. 12. 8. 13:30

  Github Actions를 이용한 배포 자동화를 학습하는 중 Gradle 빌드가 기본적으로 구성되어있는 "Java with Gradle" workflow를 생성했다. 기본적으로 아래와 같이 gradle.yml 파일을 생성해준다.

 

name: Java CI with Gradle

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@67421db6bd0bf253fb4bd25b31ebb98943c375e1
      with:
        arguments: build

  위 gradle.yml 파일을 수정하지 않고 그대로 Start commit 을 진행하면 Actions 탭에서 workflow의 진행 상황을 확인할 수 있다.

 

  실패한 경우 빨간 동그라미의 X 아이콘이 뜨며 상세 내역을 확인할 수 있다. Error: Gradle script is not executable. Gradle을 실행할 수 없다고 한다. 이에 대한 해결책으로 chmod 명령어를 통해 gradle에 실행 권한을 부여하면 된다.

 

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

  gradle 실행 권한을 부여하는 작업이다. 위 코드를 gradle.yml 파일에 추가적으로 작성한 후 create commit을 진행한다.

 

  이제 Actions 탭으로 돌아가 확인해보면 정상적으로 전 workflow 작업이 완료된 것을 확인할 수 있다.

 

참고) https://spacetech.dk/error-gradle-script-home-runner-work-gradlew-is-not-executable.html