marc_s
marc_s

Reputation: 754478

Trying to get build output artifacts from Azure CI/CD

I must be getting old - or something else.... but I can't wrap my head around what I'm trying to do here.

I have a fairly simple .NET Core command line utility, code is hosted in Azure Devops Git repo, and I've set up continuous integration in Azure Devops with a build pipeline. This works like a charm - new checking comes in, code gets compiled and unit tests get run - great.

But the next step seems to elude me. I'm coming from tools like CruiseControl or Atlassian Bamboo, and there we used to have a separate "Test" build - one that would be triggered manually, do the same thing (build the code, run the tests) and then package up the build output into an "artifact" of some sort - a ZIP file, an MSI installer - whatever.

I was trying to accomplish the same thing in Azure Devops - but I can't seem to see the forest for the trees....

There's the "Artifacts" section - so naturally, I thought it would be a breeze to add another step to my build pipeline and get my results as needed. But no matter what I do, what I try - "Archive Files", "Published Build Artifacts" or whatever else I've stumbled across, I just cannot seem to get my build result into a form so that I can download it from Azure Devops once the build is completed.

What on earth do I need to do?? I was expecting to be able to go into the "Artifacts" and somehow pick my build and get my output - as a ZIP or whatever - but that doesn't seem to be the case. "Artifacts" asked for feeds - like NuGet or Maven feeds, if I understood correctly - but that's not what I'm after here....

Where's that one amazingly well written blog post or tutorial that can explain how to set this up?

My build YAML so far looks like this:

# .NET Desktop

trigger:
- none

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

and then I tried the "archive files" step:

# Archive files - compress files into .7z, .tar.gz, or .zip
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)' 
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' 
    replaceExistingArchive: true 
    verbose: 1

and also the "published pipeline artifacts":

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Pipeline.Workspace)'
    artifact: 'BfhInfoPackage'
    publishLocation: 'pipeline'

but in neither case, I'm finding any "results" being shown anywhere for me to download or fetch ....

Upvotes: 0

Views: 2625

Answers (3)

stefan
stefan

Reputation: 156

Have you taken a look at the published folder?

Pipeline Build Summary

It took me a while to find this location when I first came across azure pipelines.

Upvotes: 2

Leo Liu
Leo Liu

Reputation: 76760

Where's that one amazingly well written blog post or tutorial that can explain how to set this up?

According to the document Overview of artifacts in Azure Pipelines:

You can publish and consume many different types of packages and artifacts with Azure Pipelines. Your continuous integration/continuous deployment (CI/CD) pipeline can publish specific package types to their respective package repositories (NuGet, npm, Python, and so on). Or you can use build artifacts and pipeline artifacts to help store build outputs and intermediate files between build steps. You can then add onto, build, test, or even deploy those artifacts.

So, the artifact type in Azure Pipelines can be a specific package repository (NuGet, npm, Python, etc.), or it can store build output and intermediate files.

Then we need to take different processing methods for different types of artifacts. If our artifact is a specific package repository, then we usually use tasks such as nuget pack/publish and maven publish to publish the artifact to the corresponding feed. But if the artifact is only intermediate files between build steps, then we need to manually process these outputs, pack and publish what we want into an artifact. This process can be simply regarded as select files and publish artifacts. Usually we will use copy file and PublishBuildArtifacts these two tasks to complete it. Copy file copies the file to a folder we defined, the default is $(build.artifactstagingdirectory), and then the PublishBuildArtifacts task will publish it to Azure Pipelines so that we can use it in the azure pipeline Download it directly from the build result.

You could check the document Artifacts in Azure Pipelines for some more details.

Upvotes: 1

Krzysztof Madej
Krzysztof Madej

Reputation: 40603

Azure Artifacts is a feed and you will not find your regular artifacts until you publish them to feed. If you want to publish your artifact for later use you should use one of these two tasks:

First task is recommended to use as it provide support for both multistage and classic release pipelines.

Looking at your archive definition I see that you publish your artifact here $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip, but you are trying to publish '$(Pipeline.Workspace)'. Please change your targetPath to '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' and you should be able to see your artifact in a place mentioned by @Stefan.

Closing this targetPath is:

The path of the file or directory to publish. Can be absolute or relative to the default working directory. Can include variables, but wildcards are not supported.

Upvotes: 2

Related Questions