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

Suppose I want to build a pipeline of a code which will print "Hello from CICD" in Azure Devo

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:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745099121a4611165.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信