【问题标题】:Azure Pipeline Gradle build fails for Spring春季 Azure Pipeline Gradle 构建失败
【发布时间】:2019-05-03 13:40:43
【问题描述】:

我正在尝试通过 Yaml 管道在 Azure 上构建和部署 Spring API。但是我在 spring application gradle build 过程中遇到错误。

Error: /home/vsts/work/1/s/gradlew failed with return code: 1

找不到 org.springframework.boot:spring-data-rest-hal-browser:

扩展错误,

Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-data-rest-hal-browser:.
  Required by:
      project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 39s
1 actionable task: 1 executed
Error: /home/vsts/work/1/s/gradlew failed with return code: 1
    at ChildProcess.<anonymous> (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.151.0/node_modules/vsts-task-lib/toolrunner.js:639:25)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
##[error]Error: /home/vsts/work/1/s/gradlew failed with return code: 1
##[section]Finishing: Gradle

我尝试过的事情。

我尝试更改在我的项目中指定 spring-data-rest-hal-browser 的版本。 compile("org.springframework.boot:spring-data-rest-hal-browser")compile("org.springframework.boot:spring-data-rest-hal-browser:2.4.0.RELEASE") 最后 compile("org.springframework.boot:spring-data-rest-hal-browser:3.0.8.RELEASE")

但还是一样的错误结果

这是我的仓库中当前的 build.gradle 文件

plugins {
    id 'org.springframework.boot' version '2.1.3.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

group = 'com.test.spring.api'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.11'

repositories {
    mavenCentral()
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    runtimeOnly 'mysql:mysql-connector-java'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    developmentOnly("org.springframework.boot:spring-boot-devtools")

    compile("org.springframework.boot:spring-boot-starter-data-rest")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("org.springframework.boot:spring-data-rest-hal-browser")
    compile("org.springframework.data:spring-data-rest-webmvc:3.1.5.RELEASE")
}

这是我当前的 azure-pipelines.yml 文件

# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

steps:
- task: Gradle@2
  inputs:
    workingDirectory: '$(system.defaultWorkingDirectory)'
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    tasks: 'build'

- task: CopyFiles@2
  displayName: 'Copy Files to: Wireframe Directory on development server'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'

    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- script: 
      cd '$(Build.ArtifactStagingDirectory)';
      ls

- task: FtpUpload@1
  displayName: 'FTP Upload: $(Build.ArtifactStagingDirectory)'
  inputs:
    credentialsOption: inputs

    serverUrl: '[test server url]'

    username: '[test username] '

    password: '[test password] '

    rootDirectory: '$(Build.ArtifactStagingDirectory)'

    remoteDirectory: D:\home\site\wwwroot\webapps\ROOT\

    preservePaths: true

我希望能够通过构建和部署 spring 应用程序的 Azure devops 管道将我的代码推送到服务器 URL,从而自动将我的 spring 应用程序部署到服务器 URL。

谢谢

【问题讨论】:

    标签: java spring azure spring-boot azure-pipelines


    【解决方案1】:

    所以我通过使用Microsoft Azure Repository for Intellij on Github: see here 的帮助对 build.gradle 文件和构建管道进行了一些更改来解决了这个问题

    我的新 build.gradle 文件如下所示:

    plugins {
        id 'org.jetbrains.intellij' version '0.4.1' apply false
        id 'org.springframework.boot' version '2.1.3.RELEASE'
        id 'java'
    }
    
    /**
     *This is task for update Gradle wrapper version.
     */
    task wrapper(type: Wrapper) {
        gradleVersion = '4.7'
        distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
    }
    
    apply plugin: 'io.spring.dependency-management'
    
    group = 'com.test.spring.api'
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = '1.8'
    
    repositories {
        mavenCentral()
    }
    
    allprojects {
    
    configurations {
        developmentOnly
        runtimeClasspath {
            extendsFrom developmentOnly
        }
    }
    
        repositories {
            mavenCentral()
        }
    }
    
    task unitTest(type: Test) {
        exclude '**/ApplicationTests/**'
    }
    
    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-data-rest'
        runtimeOnly 'mysql:mysql-connector-java'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'
        developmentOnly("org.springframework.boot:spring-boot-devtools")
    
        compile("org.springframework.boot:spring-boot-starter-data-rest")
        compile("org.springframework.boot:spring-boot-starter-data-jpa")
        compile group: 'org.springframework.data', name: 'spring-data-rest-hal-browser', version: '3.0.8.RELEASE'
        compile("org.springframework.data:spring-data-rest-webmvc:3.1.5.RELEASE")
    }
    
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    
        tasks.withType(FindBugs) {
            ignoreFailures = true
            reports {
                html { enabled = true }
                xml.enabled = !html.enabled
            }
        }
    
        /**
         * Preparing for release build
         */
        task prepRelease() {
        }
    

    还修改了 azure-pipelines.yml 文件以包含堆栈跟踪和信息,以帮助调试其他 gradle 和构建错误。

     tasks: 'build --stacktrace --info'
    

    【讨论】:

      猜你喜欢
      • 2018-11-05
      • 2021-06-10
      • 1970-01-01
      • 1970-01-01
      • 2020-12-15
      • 2021-04-27
      • 2015-08-22
      • 2014-03-30
      相关资源
      最近更新 更多