1
votes

I am trying to stand up a simple CI/CD process for our single page React application. The CI has been set up to npm build the React application and publish the build archive (.zip) to the $(Build.ArtifactStagingDirectory).

enter image description here

enter image description here

The CD process is then triggered to extract the build from the artifact .zip file and utilize the AZ CLI task to push the files to the Azure Blob Storage account hosting the static website.

enter image description here

enter image description here

The deployment completes successfully, however no files are published to the blob storage account. I was assuming that it had something to do with the --source flag of the AZ CLI command and tried to utilize the $(Build.DefaultWorkingDirectory)/$(Build.BuildId) environment varialbe as the source.

enter image description here

This however caused the deployment to fail with the following error.

The term 'Build.DefaultWorkingDirectory' is not recognized as the name of a cmdlet

I am unsure of how the DevOps directories are structured or how the AZ CLI interacts with them via the --source flag but any tips or suggestions would be greatly appreciated.

2
Here is the DevOps directories structure: docs.microsoft.com/en-us/azure/devops/pipelines/build/…Doris Lv

2 Answers

2
votes

The term 'Build.DefaultWorkingDirectory' is not recognized as the name of a cmdlet

Since you are using CD Process to start azure cli deployment, it seems that you are using the Release Pipeline.

Based on my test, I could reproduce this issue in Release Pipeline.

The root cause of this issue is that the variable Build.DefaultWorkingDirectory couldn't be used in Release Pipeline.

This variable only could be used in Build Pipeline(CI Process).

To solve this issue, you could try to use the variable:$(system.DefaultWorkingDirectory) .

Extract files Task

enter image description here

Azure CLI script sample:

az storage blob upload-batch --account-name $(Name) --account-key $(key) -s $(system.DefaultWorkingDirectory)/$(build.buildid) --pattern * -d xxx

Here is a Doc about the variables in Release Pipeline.

On the other hand, in addition to Azure Cli scripts, you can also directly use Azure file copy task. It will be more convenient.

0
votes

First: Refer to the DevOps directories structure.

Second: You could check artifacts in DevOps: enter image description here You will see the page like below. Download the artifacts to local for checking details: enter image description here

Finally, if you are very new to this, follow the video about deploy React apps to Azure.