Bitbucket 管道找不到 Gradle

Bitbucket pipelines could not find Gradle

我用 Java 11 和 Gradle 6.2 创建了一个项目。我配置了 Bitbucket 管道并推送了更改,但 Bitbucket 无法找到 Gradle 到 运行 它的命令。 我使用了这个管道配置 yml:

image: openjdk:11

pipelines:
  default: #this runs for any unspecified branches
    - step:
        name: Install dependencies
        caches:
          - gradle
        script:
          - echo 'Put any bash command here'
          - java -version
    - step:
        name: Run tests
        script:
          - bash ./gradlew test
    - step:
        name: Build artifacts
        script:
          - bash ./gradlew clean build
        artifacts:
          - build/**

  pull-requests:
    '**': #this runs as default for any branch not elsewhere defined
      - step:
          name: Install dependencies
          caches:
            - gradle
          script:
            - echo 'Put any bash command here'
            - java -version
      - step:
          name: Run tests
          script:
            - bash ./gradlew test
      - step:
          name: Build artifacts
          script:
            - bash ./gradlew clean build
          artifacts:
            - build/**

  branches:
    master: #this runs only 'master' branch
      - step:
          name: Install dependencies
          caches:
            - gradle
          script:
            - echo 'Put any bash command here'
            - java -version
      - step:
          name: Run tests
          script:
            - bash ./gradlew test
      - step:
          name: Build artifacts
          script:
            - bash ./gradlew clean build
          artifacts:
            - build/**

      - step:
          name: Deploy artifacts to the server
          deployment: production
          script:
            - pipe: atlassian/scp-deploy:0.3.3
              variables:
                USER: $SERVER_USER
                SERVER: $SERVER_IP
                VERSION: $BUILD_VERSION
                REMOTE_PATH: '/var/autotrack'
                LOCAL_PATH: 'build/libs/autotrack-$VERSION.jar' 


但是我得到了以下错误:

bash ./gradlew test
bash: ./gradlew: No such file or directory

我该如何解决这个问题?

你能运行用这个修改后的步骤构建吗?

- step:
    name: Run tests
    script:
      - bash ls -lart
      - bash ./gradlew test

我希望这能澄清问题。

openjdk:11 图片不包含 Gradle。这就是为什么我们需要在一个地方使用另一个包含 Java 和 Gradle 的图像。例如,可以使用此 gradle:6.3.0-jdk11 图像。

image: gradle:6.3.0-jdk11

pipelines:
  default:
    - step:
        name: Test and Build
        script:
          - gradle clean build