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 |2 Answers
Reset to default 0You 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:
go build
. You can usego 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