Ritesh Gupta
Ritesh Gupta

Reputation: 1

How to deploy multiple artifacts in a release using Azure devops

We are planning to migrate our current CICD setup which includes Jira and Jenkins, to Azure DevOps but we need suggestion how we can tackle below scenario in Azure DevOps:

  1. We have multiple artifacts in Jira ticket( which can varies from 10 to 200). When we move the ticket to different column in kanban board it triggers jenkins deployment job which deploys all these artifacts at once as one release

But we are not able to find how we can achieve this in azure releases, as it only allows one artifacts in one release. How can we deploy multiple artifacts like above in a release

Upvotes: 0

Views: 1617

Answers (1)

Leo Liu
Leo Liu

Reputation: 76910

You could simplify it so instead of deleting the content how about put each artifact in a sub folder of the $(Build.ArtifactStagingDirectory) So by just appending /Api or /App I could create specific publish folders that I could then push onto the azure pipeline.

You can then have as many artifacts as you need.

The important parts to take from this are that publishWebProjects needs to be set to false or it defaults to true and then ignores the projects line below, and the output path puts the content in a sub folder.

# This need to be false in order for the specific project to be published
 publishWebProjects: False
 projects: '**/DevOpsApp.csproj'
 arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/App'

and pathtoPublish need to then point to the sub folder

pathtoPublish: '$(Build.ArtifactStagingDirectory)/App'

Full example file below:

steps:
- task: DotNetCoreCLI@2
  displayName: 'Build'
  inputs:
    command: 'build'
    projects: '**/DevOpsApi.csproj'
    arguments: '--configuration $(buildConfiguration)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    projects: '**/*Tests.csproj'
    arguments: '--configuration $(buildConfiguration)'
    testRunTitle: 'Unit Tests'

# Publish the artifact
- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    # This need to be false in order for the specific project to be published
    publishWebProjects: False
    projects: '**/DevOpsApi.csproj'
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/Api'
    zipAfterPublish: True

# Publish the artifact for the pipelines to use
- task: PublishBuildArtifacts@1
  displayName: 'Publishing WebAPI Artifact'
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)/Api' 
    artifactName: 'TestWebApi-Wip'

Upvotes: 1

Related Questions