포스트

Github Actions - gradle 버전 지정하기

spring boot 프로젝트를 github actions를 통해 build 할 때 gradle 버전을 명시해주는 방법

1
2
3
4
5
6
7
8
9
10
11
12
13
jobs:
  gradle_version_change:  
    runs-on: ubuntu-latest
    steps:
    - ..
    
    - name: Setup Gradle
      uses: gradle/actions/setup-gradle@v3
      with:  
        gradle-version: 8.7
          
    - name: 테스트 및 빌드  
      run: gradle clean build

기존에 gradle/gradle-build-action@버전 형식으로 사용하던 것이 gradle/actions/setup-gradle@버전 형식으로 대체되었다고 한다.

대체되었지만 기존에 사용하던 형식도 사용 가능하다!
gradle/gradle-build-action = gradle/actions/setup-gradle


gradle 버전을 생략할 경우 github actions 실행 시 기본적으로 제공되는 최신 버전(24년 5월 25일 기준 8.5)을 사용한다.


내 경우 처음 workflow를 실행할 때 gradle 버전을 명시하지 않았었는데,
실행 할 프로젝트에서 gradle 8.7 버전을 사용하고 있었기 때문에 다음과 같은 이유로 작업이 실패 되었다.

1
2
3
4
5
6
7
8
9
10
11
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'githubactions'.
> Could not resolve all artifacts for configuration ':classpath'.
  > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.5.
  Required by:
  project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.5
  > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.5 was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7' but:

...

image




참고한 사이트

이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.