How to save artifacts in Bitbucket-Pipelines

爱⌒轻易说出口 提交于 2020-02-27 06:24:06

问题


I am new to bamboo. What I try to do is collecting all .dacpac files that are created during the build process.

image: microsoft/dotnet:latest
pipelines:
 default: 
 - step: 
 script: # Modify the commands below to build your repository. 
 - cd BackgroundCode 
 - dotnet restore 
 - dotnet run 
 artifacts: 
 - '../**/*.dacpac'

The directory structure would be

'agent/build/Projects/[Projectname]/[Projectname].dacpac'.

The output of the pipeline says

Successfully generated zip archive /opt/atlassian/pipelines/agent/build/Projects/[ProjectName]/[ProjectName].dacpac

which means there are really files generated during the build process. Have I done something wrong? If no, where would I find those artifacts.


回答1:


Unfortunately according to the documentation all artifacts are deleted after the pipeline run:

https://confluence.atlassian.com/bitbucket/using-artifacts-in-steps-935389074.html

"Once a pipeline completes, whether it succeeds or fails, the artifacts are deleted."

However you can deploy artifacts to the Bitbucket downloads section, or anywhere else:

https://confluence.atlassian.com/bitbucket/deploy-build-artifacts-to-bitbucket-downloads-872124574.html

- step:
    name: Archive
    script:
      - curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"something/**"



回答2:


In bitbucket-pipelines.yml, whenever you progress to a different "step:", it will reset almost everything and behave independently to a previous step. This is not always obvious, and can be confusing.

In your previous step, you moved into a sub-folder using cd BackgroundCode. When the script progresses to the "artifacts:" step, the current working directory will reset back to its original $BITBUCKET_CLONE_DIR. So you need to cd BackgroundCode again in each step or use a path that's relative to the $BITBUCKET_CLONE_DIR, like this:

artifacts:
 - BackgroundCode/**/*.dacpac

or

step2:
 - cd BackgroundCode
 # List the files relative to the 'BackgroundCode' directory
 - find . -iname '*.dacpac'

This will now save the artifact automatically (for 7 days), and you can see it in the "Artifacts" tab at the top.



来源:https://stackoverflow.com/questions/46680138/how-to-save-artifacts-in-bitbucket-pipelines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!