Search code examples
azureazure-devopsazure-pipelinesazure-pipelines-yamlazure-artifacts

Can we have two Build.ArtifactStagingDirectory location for one repo in one azure-pipeline yaml file to publish two different debian installer


I want to create two debian installers (packageName1 & packageName2) in same repo of azure-pipeline with same feed. Below is the task of my azure-pipeline.yaml file

          - task: PublishBuildArtifacts@1
            displayName: 'Publish artifacts'
            inputs:
              pathtoPublish: '$(Build.ArtifactStagingDirectory)'
              artifactName: 'Installer package and anti-virus scan results'
        
          - task: UniversalPackages@0
            displayName: Publish univeral package-1
            inputs:
              command: publish
              publishDirectory: '$(Build.ArtifactStagingDirectory)'
              vstsFeedPublish: '$(packageFeed)'
              vstsFeedPackagePublish: '$(packageName1)'
              packagePublishDescription: ''
              versionOption: custom
              versionPublish: $(packageVersion1)
            condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))

          - task: UniversalPackages@0
            displayName: Publish univeral package-2
            inputs:
              command: publish
              publishDirectory: '$(Build.ArtifactStagingDirectory)'
              vstsFeedPublish: '$(packageFeed)'
              vstsFeedPackagePublish: '$(packageName2)'
              packagePublishDescription: ''
              versionOption: custom
              versionPublish: $(packageVersion2)
            condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))

But when I am downloading artifact for one of the package installer through az command:

az artifacts universal download \
  --organization "https://myplatform.visualstudio.com/" \
  --feed "my-feed" \
  --name $packageName1 \
  --version $packageVersion1 \
  --path .

the packages and files of packageName2 are also getting downloaded. I feel that's because I am using same Build.ArtifactStagingDirectory location to store/publish the artifacts for both packages. Can I use different location for both installer packages ?


Solution

  • You can create a subfolder under Build.ArtifactStagingDirectory for each project and publish each artifact separately.

    There aren't 'multiple artifact directories', but you can create as many folders under the directory as you want and then pass the subfolder into the build and publish tasks.