简体   繁体   English

如何获取 Java jar 文件以发布到 azure devops 中的工件部分?

[英]How to get a java jar file to publish to artifacts section in azure devops?

I want to publish a java jar file to azure devops artifacts section in azure devops.我想将 java jar 文件发布到 azure devops 中的 azure devops artifacts 部分。 Once it is there, I want to be able to setup my gradle so it can download jars from that location.一旦它在那里,我希望能够设置我的 gradle,以便它可以从该位置下载 jars。 I think I understand how to do the second step, but how to do the first step is not clear to me.我想我明白如何做第二步,但我不清楚如何做第一步。 I can use an azure pipelines task to build the jar and publish the artifact.我可以使用 azure 管道任务来构建 jar 并发布工件。 However the published artifact does not end up in the location I want.然而,发布的工件并没有在我想要的位置结束。 It ends up in an artifacts section of the pipeline run, it does not end up in the artifacts section of ADO.它最终出现在管道运行的工件部分,而不是 ADO 的工件部分。 Here is the code:这是代码:

steps:
- checkout: self
  path: 'my-repo/'
- task: Gradle@2
  displayName: Test and build jar
  inputs:
    gradleWrapperFile: 'gradlew'
    tasks: 'build'
    publishJUnitResults: false
    javaHomeOption: 'JDKVersion'
- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: '$(System.DefaultWorkingDirectory)/build/libs/commons.jar'

You can see in this image.你可以在这张图片中看到。 The green arrow points to where the artifact ends up after successful execution of the above code.绿色箭头指向成功执行上述代码后工件的最终位置。 However when I click on the artifacts section indicated by the blue arrow it is not there.但是,当我单击蓝色箭头指示的工件部分时,它不存在。 How do I get it to publish over there so it can be consumed by my build process on my local machine?我如何让它在那里发布,以便我的本地机器上的构建过程可以使用它? Thanks in advance.提前致谢。

在此处输入图片说明

PublishBuildArtifacts@1 publishes 'Build artifacts' which are later available to be downloaded by DownloadBuildArtifacts@0 in later pipeline stages or in another pipelines. PublishBuildArtifacts@1 发布“构建工件”,稍后可供 DownloadBuildArtifacts@0 在以后的管道阶段或其他管道中下载。 (And it will be only accessible where your green arrow points) (而且它只能在你的绿色箭头指向的地方访问)

'Build artifact' is not the same thing as 'Artifacts Feed' “构建工件”与“工件馈送”不同

'Artifacts Feed' serves as source of packages which can be downloaded for example by NuGet if you configure in nuget.exe as a source your 'Artifacts Feed' “Artifacts Feed”用作包的来源,如果您在 nuget.exe 中将其配置为“Artifacts Feed”的来源,则可以通过 NuGet 下载这些包

For example you can add NuGet package there using NuGet push(with firstly configured Source) https://docs.microsoft.com/en-us/azure/devops/artifacts/get-started-nuget?view=azure-devops&tabs=windows#publish-a-nuget-package-by-using-the-command-line例如,您可以使用 NuGet 推送(首先配置源)在那里添加 NuGet 包https://docs.microsoft.com/en-us/azure/devops/artifacts/get-started-nuget?view=azure-devops&tabs=windows #publish-a-nuget-package-by-using-the-command-line

To publish Universal Packages there is already task UniversalPackages@0 https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/universal-packages?toc=%2Fazure%2Fdevops%2Fartifacts%2Ftoc.json&bc=%2Fazure%2Fdevops%2Fartifacts%2Fbreadcrumb%2Ftoc.json&view=azure-devops&tabs=yaml要发布通用包,已经有任务 UniversalPackages@0 https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/universal-packages?toc=%2Fazure%2Fdevops%2Fartifacts%2Ftoc.json&bc= %2Fazure%2Fdevops%2Fartifacts%2Fbreadcrumb%2Ftoc.json&view=azure-devops&tabs=yaml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM