如何在Bitbucket-Pipelines中保存工件

Pat*_*gel 6 bamboo bitbucket-pipelines

我是竹子新手.我尝试做的是收集.dacpac在构建过程中创建的所有文件.

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

目录结构将是

'剂/建造/项目/ [项目]/[项目] .dacpac'.

管道的输出说

成功生成zip存档/opt/atlassian/pipelines/agent/build/Projects/[ProjectName]/[ProjectName].dacpac

这意味着在构建过程中确实生成了文件.我做错了什么吗?如果不是,我会在哪里找到这些文物.

Mr-*_*IDE 11

在 bitbucket-pipelines.yml 中,每当您进行到不同的“ step:”时,它都会重置几乎所有内容并独立于上一步运行。这并不总是显而易见的,并且可能会令人困惑。

在上一步中,您使用 移至子文件夹cd BackgroundCode当脚本进行到“ artifacts:”步骤时,当前工作目录将重置回其原始目录$BITBUCKET_CLONE_DIR。因此,您需要在每个步骤中再次执行或使用相对于 的cd BackgroundCode路径,如下所示:$BITBUCKET_CLONE_DIR

artifacts:
 - BackgroundCode/**/*.dacpac
Run Code Online (Sandbox Code Playgroud)

或者

step2:
 - cd BackgroundCode
 # List the files relative to the 'BackgroundCode' directory
 - find . -iname '*.dacpac'
Run Code Online (Sandbox Code Playgroud)

现在,这将自动保存工件(14 天),您可以在顶部的“工件”选项卡中看到它。


Geo*_*ser 5

不幸的是,根据文档,在管道运行后,所有工件都被删除:

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

“一旦管道完成,无论成功还是失败,都将删除工件。”

但是,您可以将工件部署到Bitbucket下载部分或其他任何地方:

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/**"
Run Code Online (Sandbox Code Playgroud)

  • 这可能已经发生了很大变化,但工件不会预先删除:它们会保留 14 天。此外,将文件上传到 bitbucket 的推荐方法是使用官方管道 https://bitbucket.org/product/features/pipelines/integrations?p=atlassian/bitbucket-upload-file (5认同)