Home > Blockchain >  How to get a java jar file to publish to artifacts section in azure devops?
How to get a java jar file to publish to artifacts section in azure devops?

Time:11-16

I want to publish a java jar file to azure devops artifacts section in azure devops. Once it is there, I want to be able to setup my gradle so it can download jars from that location. 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. 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. 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.

enter image description here

CodePudding user response:

PublishBuildArtifacts@1 publishes 'Build artifacts' which are later available to be downloaded by DownloadBuildArtifacts@0 in later pipeline stages or in another pipelines. (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'

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

To publish Universal Packages there is already task UniversalPackages@0 https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/universal-packages?toc=/azure/devops/artifacts/toc.json&bc=/azure/devops/artifacts/breadcrumb/toc.json&view=azure-devops&tabs=yaml

  • Related