最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure devops - Where does the TFS pipeline prints the output? - Stack Overflow

programmeradmin0浏览0评论

Suppose I want to build a pipeline of a code which will print "Hello from CICD" in Azure Devops on a Linux agent. Now I want to know that after the pipeline is successfully run where is the output displayed?

This is the pipeline code:

trigger: 
 - master
pool:
  name: "Default"
  demands:
    - Agent.Name -equals agent
steps: 
- task: GoTool@0
  inputs:
    version: '1.13.5'
- task: Go@0
  inputs:
    command: 'get'
    arguments: '-d'
    workingDirectory: '$(System.DefaultWorkingDirectory)/myproject'
- task: Go@0
  inputs:
    command: 'build'
    workingDirectory: '$(System.DefaultWorkingDirectory)/myproject'
- task: CopyFiles@2
  inputs:
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
  inputs:
     artifactName: drop

And in myproject contains main.go:

package main

import "fmt"

func main(){
    fmt.Println("Hello from CICD ")
}

I want to know where will be this "Hello from CICD" be printed.

Suppose I want to build a pipeline of a code which will print "Hello from CICD" in Azure Devops on a Linux agent. Now I want to know that after the pipeline is successfully run where is the output displayed?

This is the pipeline code:

trigger: 
 - master
pool:
  name: "Default"
  demands:
    - Agent.Name -equals agent
steps: 
- task: GoTool@0
  inputs:
    version: '1.13.5'
- task: Go@0
  inputs:
    command: 'get'
    arguments: '-d'
    workingDirectory: '$(System.DefaultWorkingDirectory)/myproject'
- task: Go@0
  inputs:
    command: 'build'
    workingDirectory: '$(System.DefaultWorkingDirectory)/myproject'
- task: CopyFiles@2
  inputs:
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
  inputs:
     artifactName: drop

And in myproject contains main.go:

package main

import "fmt"

func main(){
    fmt.Println("Hello from CICD ")
}

I want to know where will be this "Hello from CICD" be printed.

Share Improve this question edited Mar 4 at 6:03 Hey Hello asked Mar 3 at 10:23 Hey HelloHey Hello 134 bronze badges 4
  • It is expected that you will not see the output when using your YAML since you are using go build. You can use go run to compiles and runs your Go program in one step. See my update below for the details. – Ziyang Liu-MSFT Commented Mar 7 at 3:54
  • Hi @Hey Hello, have you checked the update below and are you able to see the output of your GO project? – Ziyang Liu-MSFT Commented Mar 10 at 9:12
  • I have not checked this. Once I check I will update you. – Hey Hello Commented Mar 10 at 10:36
  • Sure. If you have any question, feel free to let me know. – Ziyang Liu-MSFT Commented Mar 11 at 1:20
Add a comment  | 

2 Answers 2

Reset to default 0

You can find this info on Azure DevOps Docs:

  • View and manage your pipelines
  • View pipeline details

Now I want to know that after the pipeline is successfully run where is the output displayed?

The output can be seen in the pipeline log whether it's a command line script or another language (such as python). For example,

steps:
- script: |
    echo 'Hello from CICD'
  displayName: 'Print in script'

- task: PythonScript@0
  displayName: 'Print in python'
  inputs:
    scriptSource: 'filePath'
    scriptPath: 'print.py'

print.py:

print("Hello from CICD")

Result:


Update:

It is expected that you will not see the output when using your YAML since you are using go build. go build compiles your Go program and creates an executable file, but it doesn't run the program.

To see the output, you should use go run. This command compiles and runs your Go program in one step. It's useful for quickly testing or running a program without creating an executable file.

- task: Go@0
  inputs:
    command: 'custom'
    customCommand: 'run'
    arguments: '$(Build.SourcesDirectory)'

My .go file is in the root folder of my repo.

Result:

Or you can directly run go command in a CmdLine@2 task.

- task: CmdLine@2
  inputs:
    script: 'go run .'
    workingDirectory: '$(Build.SourcesDirectory)'

Result:

发布评论

评论列表(0)

  1. 暂无评论