首页 文章

如何在Bitbucket-Pipelines中保存工件

提问于
浏览
5

我是竹子新手 . 我尝试做的是收集在构建过程中创建的所有 .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'

目录结构将是

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

管道的输出说

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

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

2 回答

  • 0

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

    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/**"
    
  • 2

    在bitbucket-pipelines.yml中,无论何时进入不同的“ step: ”,它都会重置几乎所有内容,并独立地执行上一步 . 这并不总是显而易见的,并且可能令人困惑 .

    在上一步中,您使用 cd BackgroundCode 移动到子文件夹中 . When the script progresses to the "artifacts:" step, the current working directory will reset back to its original $BITBUCKET_CLONE_DIR . 所以你需要在每一步中再次 cd BackgroundCode 或使用relative to the $BITBUCKET_CLONE_DIR的路径,如下所示:

    artifacts:
     - BackgroundCode/**/*.dacpac
    

    要么

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

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

相关问题