Bitbucket pipeline artifacts could not be found

btosic December 26, 2022

Here is the complete pipeline that should publish the .net package as zip and store as an artifact. Next step should use that artifact to deploy on azure. Tab artifact is always empty. Is there anything I made wrong or it can be related to the bitbucket server?


image: mcr.microsoft.com/dotnet/sdk:6.0

pipelines:
branches:
master:
- step:
name: Build and publish .NET app
caches:
- dotnetcore
script:
- curl -sL https://deb.nodesource.com/setup_14.x | bash -
- apt-get install -y nodejs
- cd DutchKnittingCompany
- dotnet publish -o publish -c Release
- cd publish
- apt-get -y install zip
- zip -r api-$BITBUCKET_BUILD_NUMBER.zip .
artifacts:
- "*.zip"
- step:
name: Deploy .NET to Azure AppService
deployment: Azure
script:
- pipe: atlassian/azure-web-apps-deploy:1.0.1
variables:
AZURE_APP_ID: $AZURE_APP_ID
AZURE_PASSWORD: $AZURE_PASSWORD
AZURE_TENANT_ID: $AZURE_TENANT_ID
AZURE_RESOURCE_GROUP: $RESOURCE_GROUP
AZURE_APP_NAME: $APP_NAME
ZIP_FILE: 'api-$BITBUCKET_BUILD_NUMBER.zip'

 

Error I'm getting:


INFO: Starting deployment to Azure app service...
az webapp deployment source config-zip --resource-group DKCResGroup --name dkcapi --src api-40.zip
ERROR: [Errno 2] No such file or directory: '/opt/atlassian/pipelines/agent/build/api-40.zip'
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in execute
raise ex
File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 386, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 379, in _run_job
six.reraise(*sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 356, in _run_job
result = cmd_copy(params)
File "/usr/local/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 171, in __call__
return self.handler(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 441, in default_command_handler
return op(**command_args)
File "/usr/local/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 267, in enable_zip_deploy
with open(os.path.realpath(os.path.expanduser(src)), 'rb') as fs:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/atlassian/pipelines/agent/build/api-40.zip'
✖ Deployment failed.

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 29, 2022

Hello @btosic ,

Welcome to Atlassian Community!

Just sharing a bit of context, at the end of the build bitbucket will look for artifacts that are within BITBUCKET_CLONE_DIR. The BITBUCKET_CLONE_DIR is the directory in which the repository was initially cloned. More on that in Use artifacts in steps.

Looking at your YML file, it seems like you are generating the artifact inside a folder called DutchKnittingCompany/publish, while your current YML configuration is looking for *.zip files only in the root folder (BITBUCKET_CLONE_DIR).

To generate an artifact for every .zip file inside a folder called DutchKnittingCompany/publish, you should configure  the artifact section of your step as the following example : 

script:
- curl -sL https://deb.nodesource.com/setup_14.x | bash -
- apt-get install -y nodejs
- cd DutchKnittingCompany
- dotnet publish -o publish -c Release
- cd publish
- apt-get -y install zip
- zip -r api-$BITBUCKET_BUILD_NUMBER.zip .
artifacts:
- DutchKnittingCompany/publish/*.zip

Could you try using the suggestion above and let us know how it goes? 

Thank you, @btosic .

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events