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).
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.
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.
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.
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
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.
Are you sure we cannot use
Build.DefaultWorkingDirectory
in release pipeline?This is the predefined variable in Build pipeline. In the release pipeline, it will not be recognized. If possible, you could try it.
i.stack.imgur.com/ns5o1.jpg This works when in my release pipeline...
You are using the
system.DefaultWorkingDirectory
instead ofBuild.DefaultWorkingDirectory
, right?Ok, now I see, thank you, Kevin.