共用方式為


Go@0 - Go v0 工作

使用此工作來取得、建置或測試 Go 應用程式,或執行自訂 Go 命令。

語法

# Go v0
# Get, build, or test a Go application, or run a custom Go command.
- task: Go@0
  inputs:
    command: 'get' # 'get' | 'build' | 'test' | 'custom'. Required. Command. Default: get.
    #customCommand: # string. Required when command == custom. Custom command. 
    #arguments: # string. Arguments. 
  # Advanced
    #workingDirectory: # string. Working directory.

輸入

command - 命令
string。 必須的。 允許的值:get、、、buildtestcustom 預設值:get

指定要執行的 Go 命令。 使用 Custom 執行此處未列出的命令。


customCommand - 自定義命令
stringcommand == custom時為必要項。

要執行的自定義 Go 命令。 例如,若要執行 go version,請使用 version


arguments - 自變數
string

選取命令的選擇性自變數。 例如,針對 go build 命令使用建置時間自變數。


workingDirectory - 工作目錄
string

您要命令執行的工作目錄。 當空白時,會使用存放庫根目錄(適用於組建)或成品(適用於發行),這是 $(System.DefaultWorkingDirectory)的值。


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制項選項和一般工作屬性

輸出變數

沒有。

備註

使用此工作來取得、建置或測試 Go 應用程式,或執行自訂 Go 命令。

範例

variables:
  GOBIN:  '$(GOPATH)/bin' # Go binaries path
  GOROOT: '/usr/local/go1.11' # Go installation path
  GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
  modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

steps:
- task: GoTool@0
  displayName: 'Use Go 1.10'

- task: Go@0
  displayName: 'go get'
  inputs:
    arguments: '-d'

- task: Go@0
  displayName: 'go build'
  inputs:
    command: build
    arguments: '-o "$(System.TeamProject).exe"'

- task: ArchiveFiles@2
  displayName: 'Archive files'
  inputs:
    rootFolderOrFile: '$(Build.Repository.LocalPath)'
    includeRootFolder: False

- task: PublishBuildArtifacts@1
  displayName: 'Publish artifact'
  condition: succeededOrFailed()

需求

要求 說明
管線類型 YAML、傳統組建、傳統版本
執行於 Agent、DeploymentGroup
需求 沒有
功能 此工作不符合作業中後續工作的任何需求。
命令限制 任意
Settable 變數 任意
代理程式版本 所有支援的代理程式版本。
工作類別 建造