how to remove build artifact from Azure DevOps pipeline or provide folder exchange between jobs?

  Kiến thức lập trình

Is there any way to remove Build Artifact produced in one job of the pipeline, like:

    - task: PublishPipelineArtifact@1
      inputs:
        targetPath: '$(Agent.BuildDirectory)/${{ parameters.buildPath}}/'
        artifact: 'RestoredBuilds'
        publishLocation: 'pipeline'  

to be re-used by another job. These files have no values outside of the pipeline and had better remove to empty space. If it is not possible, is there any other way of folders/files exchange between jobs of the same pipeline?

1

According to your description, you want to delete the Build Artifact produced in the pipeline while retaining the pipeline runs to avoid occupying the Azure Artifacts storage.

However, according to this Q&A, pipeline artifacts are not deletable or overwritable. Currently, you can only delete the pipeline run, and the pipeline artifacts will be deleted along with the run. You can set retention policies for builds, which will delete older runs to save storage space.

If it is not possible, is there any other way of folders/files exchange between jobs of the same pipeline?

  1. Using a File Share for Artifact Exchange

    You can publish the pipeline artifact to a file share that must be accessible from the pipeline agents. Then you can download the artifact in the subsequent jobs.

  - task: PublishPipelineArtifact@1
    inputs:
      targetPath: '$(Agent.BuildDirectory)/${{ parameters.buildPath}}/'
      artifact: 'RestoredBuilds'
      publishLocation: 'filepath'
      fileSharePath: '\myshare(Build.DefinitionName)\(Build.BuildNumber)'
  1. Using the Copy Files Task

    You can use the Copy Files task to copy the files to a file share that must be accessible from the pipeline agents. Then you can copy the files back in the subsequent jobs.

  - task: CopyFiles@2
    inputs:
      SourceFolder: '$(Agent.BuildDirectory)/${{ parameters.buildPath}}/'
      Contents: '**'
      TargetFolder: '\\network-share\path\to\folder'
  1. Running Jobs on the Same Self-Hosted Agent

    You can specify certain demands of the agent to make sure the pipeline jobs run on the same self-hosted agent. In the first job, you can copy and store the files to a path on the self-hosted agent, then in the subsequent jobs, you can access the path as they are run on the same agent.

pool:
  name: Default
  demands: SpecialCapabilities  # exists check for capabilities 

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT