Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,364,064
Community Members
 
Community Events
168
Community Groups

Pipelines script not finding artifacts. Looking in "build" folder instead of "artifacts" folder.

I am trying to build and deploy an Angular application to an Azure App Service using a self-hosted runner. Most things are working, but the step to deploy the .zip generated in a previous step is failing because it's looking in the wrong folder for the artifact.

 

Here is my pipeline file: 

image: node:14

pipelines:
branches:
develop:
- step:
name: Installation
caches:
- node
script:
- npm install
artifacts:
- node_modules/**
- step:
name: Node Build
script:
- npm run build
- apt update && apt install zip
- (cd ./dist/test; zip -r ../../test.zip .)
artifacts:
- test.zip
- step:
name: Deploy
deployment: Development
runs-on:
- self.hosted
- windows
script:
- az login --service-principal --username $env:AZURE_APP_ID --password $env:AZURE_PASSWORD --tenant $env:AZURE_TENANT_ID
- az webapp deployment source config-zip --resource-group $env:AZURE_RESOURCE_GROUP --name $env:AZURE_APP_NAME --src test.zip

 

It fails on the last line of the pipeline when it tries to access "test.zip" stating that the .zip file can't be found: 

ERROR: [Errno 2] No such file or directory: 'C:\\runner\\atlassian-bitbucket-pipelines-runner-1.363\\temp\\f90cfa4e-8d70-51b4-8eab-aec83d478f52\\1663598185750\\build\\test.zip'

 

I can RDP into the VM that I'm running the deploy steps on see that the "test.zip" file (along with the node_modules artifact) is being placed in the following directory: 

C:\\runner\\atlassian-bitbucket-pipelines-runner-1.363\\temp\\f90cfa4e-8d70-51b4-8eab-aec83d478f52\\1663598185750\\artifacts\\test.zip

I have also grabbed the "test.zip" file while the pipeline is running to validate it has the correct files within, and it does. 

Is there a way to point the last script to the "artifacts" folder instead of the "build" folder? Or a way to place the artifact in the "build" folder instead? Or any other way to properly access the artifact from the last step in my pipeline? 

1 answer

1 accepted

0 votes
Answer accepted

I found a solution and I'll post it here in case anyone else looks in the future.

I basically search for the .zip file in powershell in the script section and save the path output in a variable, trim the variable, and reference it to deploy. See my below updated script section:

script:
- $ZipPathName = (Get-ChildItem C:/runner -recurse -filter "test.zip").fullname | Out-String
- $ZipPathNameTrimmed = $ZipPathName.replace("`n","").replace("`r","")
- az login --service-principal --username $env:AZURE_APP_ID --password $env:AZURE_PASSWORD --tenant $env:AZURE_TENANT_ID
- az webapp deployment source config-zip --resource-group $env:AZURE_RESOURCE_GROUP --name $env:AZURE_APP_NAME --src $ZipPathNameTrimmed

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS

Atlassian Community Events