java - Spring Boot 应用程序的 Azure 发布管道表示没有可发布的工件

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

我想使用 Azure DevOps 在 Azure 上部署我的 Spring Boot (Java) 应用程序。但是,我似乎无法让发布管道正常工作。

我已经使用以下 azure-pipelines.yml 创建了一个 Azure 构建管道:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'package'
    options: '-Dmaven.test.skip=true'
    mavenOptions: '-Dmaven.test.skip=true'
    publishJUnitResults: false
    javaHomeOption: 'JDKVersion'
    mavenVersionOption: 'Default'
    mavenAuthenticateFeed: false
    effectivePomSkip: false
    sonarQubeRunAnalysis: false

构建成功,下一步是创建发布管道。我选择了选项“将 Java 应用程序部署到 Azure 应用服务”。当我尝试添加工件时,我看到以下内容: Screenshot of Azure release pipeline

如您所见,我收到消息“没有可用的版本,或者最新版本没有可发布的工件”。请检查源管道。'。这告诉我构建管道没有创建工件或者其他一些设置配置不正确。我最初的想法是,我需要向 azure-pipelines.yml 添加一个步骤,以实际将工件放置在某处。

有谁知道解决办法是什么吗?

最佳答案

This tells me that the build pipeline did not create the artifact or that some other setting is configure incorrectly. My initial thought is that I need to add a step to azure-pipelines.yml that actually puts the artifact somewhere.

是的,您最初的想法是完全正确的。

当您使用发布管道部署应用程序/文件时,这将从工件中获取源代码。因此,我们需要将应用程序/文件发布到构建管道中的工件。构建输出位于未发布到工件的工作目录中,这就是您收到错误的原因,没有可用的版本或最新版本没有可发布的工件

要解决此问题,您只需添加 copy taskPublish build artifacts task在 Maven 任务之后复制 .jar 文件并将其发布到工件:

steps:
- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'package'
    ...

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: '$(system.defaultworkingdirectory)'
    Contents: '**/*.jar'
    TargetFolder: '$(build.artifactstagingdirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

然后,我们可以使用发布管道来部署构建工件:

enter image description here

关于java - Spring Boot 应用程序的 Azure 发布管道表示没有可发布的工件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59402646/

相关文章:

java - 有没有一种数据结构可以避免重复、保持顺序和随机访问

java - 缓存系统如何实现?

java - 简单的 Spring Boot POST 不起作用

azure - 如何将变量从管道任务传递到 terraform 任务并将其应用到我的 terraform 代码中?

azure - 无法从变量组(库)更新变量

tfs-2015 - 使用 Visual Studio Online/TFS 2015 Api 创建 TFS 源分支

java - 在 JTextArea 或 JTextPane 中居中文本 - 水平文本对齐

java - POI - 无法在 osgi 中打开 xlsx 文件

java - 将 javah -jni 与 Eclipse 项目结构一起使用

java - 添加动态数量的监听器(Spring JMS)