How to save artifacts in Bitbucket-Pipelines

后端 未结 3 1099
我寻月下人不归
我寻月下人不归 2021-02-14 12:48

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
pipe         


        
3条回答
  •  清歌不尽
    2021-02-14 13:32

    I think one good alternative is to use the bitbuckets download section like previously mentioned, however you can use their dedicated tool instead of using curl and hopping the API will not change and break your pipeline.

    https://support.atlassian.com/bitbucket-cloud/docs/deploy-build-artifacts-to-bitbucket-downloads/

    Compared to curl I think it's safer, easier to setup and easier to maintain. For example, the linked documentation shows 0.1.2 version of the tool, while the newest is 0.3.2, it required me to only update that version number and nothing else to stay up to date. I had to setup app permission key with the write access to my repositories, setup this as pipeline variable, setup my account name as a pipeline variable (the linked documentation described it pretty well) and then add a simple step to my pipeline yaml file. One disadvantage I can think of is that for bigger files curl might be better. So take it as yet another way of doing things, not as the ultimate way of doing everything.

    My example yaml, you use some container to build your sources, it, you have your Makefile build step defined, then I rename my output artifact file and postfix a build ID (this way I will have multiple output files in my download section, not just the latest). Then I will make sure the next step will have access to these artifacts by adding the artifacts in the build step:

    artifacts:

    • build/output-*.zip

    And then the last deploy step will have access to the zip and will upload it for you, their tool doesn't need anything else just 3 variables setup, user name, app key and the file to upload.

    For completion the example pipeline yaml:

    image: 
    
    pipelines:
      default:
        - step:
            name: 'Build'
            script:
              - make all
              - mv build/output.zip build/output-$BITBUCKET_BUILD_NUMBER.zip
            artifacts:
              - build/output-*.zip
    
        - step:
            name: 'Deploy the output into the download section'
            script:
              - pipe: atlassian/bitbucket-upload-file:0.3.2
                variables:
                  BITBUCKET_USERNAME: $BITBUCKET_USERNAME
                  BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
                  FILENAME: "build/output-$BITBUCKET_BUILD_NUMBER.zip"
    

提交回复
热议问题