分享方式:


Go@0 - Go v0 工作

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

Syntax

# 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 - 自訂命令
string. 當 時為 必要 command == 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
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任意
Settable 變數 任意
代理程式版本 所有支援的代理程式版本。
工作類別 建置