DeleteFiles@1 - 파일 v1 작업 삭제

폴더 또는 패턴과 일치하는 파일을 삭제합니다.

파일 또는 폴더를 삭제합니다. 미니매치 패턴은 폴더 경로가 아닌 파일 경로만 일치합니다.

Syntax

# Delete files v1
# Delete folders, or files matching a pattern.
- task: DeleteFiles@1
  inputs:
    #SourceFolder: # string. Source Folder. 
    Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.
    #RemoveSourceFolder: false # boolean. Remove SourceFolder. Default: false.
  # Advanced
    #RemoveDotFiles: false # boolean. Remove files starting with a dot. Default: false.
# Delete files v1
# Delete folders, or files matching a pattern.
- task: DeleteFiles@1
  inputs:
    #SourceFolder: # string. Source Folder. 
    Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.
    #RemoveSourceFolder: false # boolean. Remove SourceFolder. Default: false.
# Delete files v1
# Delete folders, or files matching a pattern.
- task: DeleteFiles@1
  inputs:
    #SourceFolder: # string. Source Folder. 
    Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.
# Delete Files v1
# Delete files or folders. (The minimatch patterns will only match file paths, not folder paths).
- task: DeleteFiles@1
  inputs:
    #SourceFolder: # string. Source Folder. 
    Contents: 'myFileShare' # string. Required. Contents. Default: myFileShare.

입력

SourceFolder - 원본 폴더
string.

원본 폴더가 비어 있으면 태스크는 $(Build.SourcesDirectory) 가 지정된 것처럼 리포지토리의 루트 폴더에서 파일을 삭제합니다. 빌드에서 원본 디렉터리 외부에서 아티팩트가 생성되는 경우 빌드 에이전트 작업 디렉터리에서 파일을 삭제하도록 지정 $(Agent.BuildDirectory) 합니다.


Contents - 내용을
string. 필수 요소. 기본값은 myFileShare입니다.

삭제할 파일/폴더 경로입니다. 여러 줄의 미니매치 패턴을 지원합니다. 각 행은 다음 줄로 이동하기 전에 처리됩니다. 파일 일치 패턴에 대해 자세히 알아봅니다. 예를 들면 다음과 같습니다.

  • **/* 는 루트 폴더의 모든 파일 및 폴더를 삭제합니다.
  • temp 는 루트 폴더의 임시 폴더를 삭제합니다.
  • temp*임시로 시작하는 이름을 사용하여 루트 폴더의 모든 파일 또는 폴더를 삭제합니다.
  • **/temp/*temp라는 하위 폴더의 모든 파일 및 폴더를 삭제합니다.
  • **/temp*임시로 시작하는 이름의 파일 또는 폴더를 삭제합니다.
  • !(*.vsix).vsix 확장명이 없는 루트 폴더의 모든 파일을 삭제합니다.

RemoveSourceFolder - SourceFolder 제거
boolean. 기본값은 false입니다.

제거를 시도한 후 원본 폴더를 제거 Contents하려고 합니다. If you want to remove the whole folder, set this to true and set Contents to *.


RemoveDotFiles - 점으로 시작하는 파일 제거
boolean. 기본값은 false입니다.

점으로 시작하는 파일을 삭제합니다. 예: .git.dockerfile 명시적으로 지정되지 않은 경우 이러한 파일을 생략합니다. 예: /.* 미니매치에 대해 자세히 알아보세요.


작업 제어 옵션

모든 작업에는 작업 입력 외에도 제어 옵션이 있습니다. 자세한 내용은 제어 옵션 및 일반적인 작업 속성을 참조하세요.

출력 변수

없음

설명

이 작업을 사용하여 에이전트 작업 디렉터리에서 파일 또는 폴더를 삭제합니다.

여러 패턴 삭제

이 예제에서는 모든 파일을 test삭제some/file하고 모든 하위 디렉터리에 있는 모든 파일을 삭제bin합니다.

steps:
- task: DeleteFiles@1
  displayName: 'Remove unneeded files'
  inputs:
    contents: |
      some/file
      test*
      **/bin/*

하나의 하위 디렉터리를 제외한 모든 하위 디렉터리 삭제

이 예제에서는 삭제 some/onesome/three 되지만 some/four 그대로 둡니다some/two.

steps:
- task: DeleteFiles@1
  displayName: 'Remove unneeded files'
  inputs:
    contents: |
      some/!(two)

중괄호 확장을 사용하여 삭제

이 예제는 삭제 some/one 되지만 some/four 그대로 유지 some/two 됩니다 some/three.

steps:
- task: DeleteFiles@1
  displayName: 'Remove unneeded files'
  inputs:
    contents: |
      some/{one,four}

점으로 시작하는 파일 삭제

이 예제에서는 모든 .txt 파일을 삭제합니다. 점으로 시작하는 파일도 삭제됩니다.

steps:
- task: DeleteFiles@1
  displayName: 'Remove unneeded files'
  inputs:
    contents: |
      /some/*.txt
    removeDotFiles: true

요구 사항

요구 사항 Description
파이프라인 유형 YAML, 클래식 빌드
실행 중 에이전트, DeploymentGroup
요청 None
Capabilities 이 작업은 작업의 후속 작업에 대한 요구를 충족하지 않습니다.
명령 제한 이 작업은 다음 명령 제한을 사용하여 실행됩니다. 제한됨
설정 가능한 변수 이 작업에는 다음 변수를 설정할 수 있는 권한이 있습니다. 변수 설정이 비활성화되었습니다.
에이전트 버전 2.182.1 이상
작업 범주 유틸리티
요구 사항 Description
파이프라인 유형 YAML, 클래식 빌드
실행 중 에이전트, DeploymentGroup
요청 None
Capabilities 이 작업은 작업의 후속 작업에 대한 요구를 충족하지 않습니다.
명령 제한 모두
설정 가능한 변수 모두
에이전트 버전 1.92.0 이상
작업 범주 유틸리티