2021年4月8日星期四

Azure pipeline foreach loop

I am having some problem to figure out the issue in this pipeline.

I have a GitHub repo which contains one folder named dist. This folder has inside multiple files and folder. Here is the structure of my git hub:

├── README.md  ├── client_pipeline.yaml  ├── client_template.yaml  └── dist      ├── ReportPhishingOutlookAddIn.xml      └── ReportPhishingOutlookAddInWeb          ├── Content          ├── Dialog.html          ├── Functions          ├── Images          └── Scripts  

What I want to do, is when I create a new folder in this repo my pipeline should trigger and upload the dist folder content inside this new folder and save it in azure storage.

So I decided to go with a azure pipeline template first to define the logic of the pipeline:

Client_template.yaml

parameters:    storageaccount: ''    client: []  steps:    - $:      - task: AzureCLI@2        displayName: 'Azure CLI'        inputs:          AzureSubscription: '<mysubscription>'          scriptType: bash          scriptLocation: inlineScript          inlineScript: |             az storage blob upload-batch --source dist --destination '$web/${client}' --account-name $ --output table --no-progress  

And I created another pipeline to call this template.

client_pipeline.yaml

variables:    - name: storageaccount      value: <mystorageaccount>    steps:    - template: client_template.yaml      parameters:        storageaccount: $        client: ["folder","folder1"]  

The second pipeline I am using it to give me freedom to add as many clients as I want and the pipeline should just create them in an azure storage account.

When I run my pipeline, it builds everything without any problem, but when I go in my storage account I have 2 issues.

The first one is that the folder name is ${client} and not the actual name of the name I specified in my array.

The second issue is that the upload, uploads only the main folder and none of the subfolders.

Any help guys please?

EDIT: I solved the issue number 1, now I am able to create multiple folders. But still it doesn't copy all the subfolders and file in folder inside dist

https://stackoverflow.com/questions/67005301/azure-pipeline-foreach-loop April 08, 2021 at 09:43PM

没有评论:

发表评论