Output of Powershell file in Jenkins Console Output

Viewed 32

I have a PowerShell script, NuGetPack.ps1 as following:

$path = $args[0]
Get-ChildItem -Path $path -Recurse -Force | 
Foreach-Object {
   Write-Output nuget pack $_.FullName 
   -IncludeReferencedProjects 
   -properties configuration=release -outputdirectory NugetPackages
}

This file is being called in the Jenkins Declarative Pipeline as follows:

stage("NuGet Pack"){
        steps{
            script{
                def path = ".\\$projectDir\\src\\**\\**\\**\\*.nuspec"
                powershell(
                    script: "powershell -executionPolicy RemoteSigned -File .\\'Powershell Scripts'\\NuGetPack.ps1 $path")
            }
        }
    }

Issue: I am not getting the logs/output generated by the Powershell script file in the Console Output of the Jenkins pipeline. The console output is blank for the stage defined in the Jenkins file.

Jenkins Console Output

Can anyone please help me in figuring out how to get the output/log in Jenkins Console Output as I am getting while running that script in Powershell?

0 Answers
Related