CmdLine@2 - 명령줄 v2 작업

이 작업을 사용하여 Windows에서 Linux, macOS 및 cmd.exe Bash를 사용하여 명령줄 스크립트를 실행합니다.

Syntax

# Command Line v2
# Run a command line script using Bash on Linux and macOS and cmd.exe on Windows.
- task: CmdLine@2
  inputs:
    script: # string. Required. Script. 
  # Advanced
    #workingDirectory: # string. Working Directory. 
    #failOnStderr: false # boolean. Fail on Standard Error. Default: false.

입력

script - 스크립트
string. 필수 요소. 기본값은 echo Write your commands here\n\necho Hello world입니다.

실행할 스크립트의 콘텐츠입니다.


script - 스크립트
string. 필수 요소. 기본값은 echo Write your commands here\n\necho Use the environment variables input below to pass secret variables to this script입니다.

실행할 스크립트의 콘텐츠입니다.


workingDirectory - 작업 디렉터리
string.

명령을 실행할 작업 디렉터리를 지정합니다. 비워 두면 작업 디렉터리가 $(Build.SourcesDirectory)입니다.


failOnStderr - 표준 오류 발생 시 실패
boolean. 기본값은 false입니다.

값이 true로 설정된 경우 표준 오류 스트림에 오류가 기록되면 작업이 실패합니다.


작업 제어 옵션

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

출력 변수

없음

설명

명령줄에는 YAML: steps.script의 바로 가기가 있습니다.

- script: # inline script
  workingDirectory: #
  displayName: #
  failOnStderr: #
  env: { string: string } # mapping of environment variables to add

일괄 처리 및 를 실행합니다. CMD 파일

Azure Pipelines는 인라인 스크립트 콘텐츠를 실행하기 위해 임시 배치 파일(.cmd)에 넣습니다. Windows CMD의 다른 일괄 처리 파일에서 일괄 처리 파일을 실행하려면 명령을 사용해야 call 합니다. 그렇지 않으면 첫 번째 일괄 처리 파일이 종료됩니다. 이렇게 하면 Azure Pipelines가 첫 번째 배치 파일까지 의도한 스크립트를 실행한 다음 배치 파일을 실행하고 단계를 종료합니다. 첫 번째 스크립트의 추가 줄은 실행되지 않습니다. Azure Pipelines 스크립트 단계에서 일괄 처리 파일을 실행하기 전에 항상 앞에 추가 call 해야 합니다.

중요

일괄 처리 파일을 실행하고 있다는 사실을 인식하지 못할 수 있습니다. 예를 들어 npm Windows에서는 를 사용하여 npm install -g설치하는 모든 도구와 함께 실제로 배치 파일이 있습니다. 항상 를 사용하여 call npm <command> Windows의 명령줄 작업에서 NPM 명령을 실행합니다.

예제

steps:
- script: date /t
  displayName: Get the date
- script: dir
  workingDirectory: $(Agent.BuildDirectory)
  displayName: List contents of a folder
- script: |
    set MYVAR=foo
    set
  displayName: Set a variable and then display all
  env:
    aVarFromYaml: someValue

요구 사항

요구 사항 Description
파이프라인 유형 YAML, 클래식 빌드, 클래식 릴리스
실행 중 에이전트, DeploymentGroup
요청 없음
Capabilities 이 작업은 작업의 후속 작업에 대한 요구를 충족하지 않습니다.
명령 제한 사항 모두
설정 가능한 변수 모두
에이전트 버전 지원되는 모든 에이전트 버전.
작업 범주 유틸리티

추가 정보