[JIRA] (JENKINS-56925) extra newline character from powershell output

7 views
Skip to first unread message

rostergek@gmail.com (JIRA)

unread,
Apr 7, 2019, 7:12:02 AM4/7/19
to jenkinsc...@googlegroups.com
gek gek created an issue
 
Jenkins / Bug JENKINS-56925
extra newline character from powershell output
Issue Type: Bug Bug
Assignee: gek gek
Components: durable-task-plugin
Created: 2019-04-07 11:11
Environment: Jenkins ver. 2.164.1
Durable Task Plugin 1.29
Labels: jenkins,pipeline,powershell
Priority: Major Major
Reporter: gek gek

When i trying to wrap some powershell script output into variable, it's adds excess \n symbol to.

Like:

script {
	VARI = powershell (returnStdout: true, script: """Write-Output foo""")
	println VARI
	}

It's outputs the following:

[Pipeline] script
[Pipeline] {
[Pipeline] powershell
[Pipeline] echo
foo

[Pipeline] }
[Pipeline] // script
[Pipeline] }

But powershell itself transmits output without `n .
How to escape it in output?

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

rostergek@gmail.com (JIRA)

unread,
Apr 7, 2019, 8:19:02 AM4/7/19
to jenkinsc...@googlegroups.com
gek updated an issue
Change By: gek
Priority: Major Trivial

jamesnswithers@gmail.com (JIRA)

unread,
Apr 8, 2019, 7:06:03 AM4/8/19
to jenkinsc...@googlegroups.com
James Withers commented on Bug JENKINS-56925
 
Re: extra newline character from powershell output

I believe this is a feature of Powershell's Write-*. You can add -NoNewLine as a parameter.

 

rostergek@gmail.com (JIRA)

unread,
Jun 6, 2019, 9:04:03 AM6/6/19
to jenkinsc...@googlegroups.com
gek commented on Bug JENKINS-56925

But how?

Only way i see is use Write-Host -NoNewline , but it's output cannot be passed throw:

 

https://serverfault.com/questions/859826/output-is-truncated-in-jenkins-job-when-launching-powershell-script-remotely-usi

 

For some reason Write-Host -NoNewline output cannot be assigned to variable.

peh@vizrt.com (JIRA)

unread,
Jun 17, 2019, 12:05:02 PM6/17/19
to jenkinsc...@googlegroups.com

 

Maybe this is related...

The console output is different for the 2 scripts below - depending on if 'returnStdout: true' is used or not.
The second script does it right, the first - where 'returnStdout: true' is used - does it wrong.
I'm quite sure that the first script also worked correctly 2 months or so ago.

pipeline {
    agent any
    stages {
        stage('Test') {
            steps  {
                script {
                    stdo = powershell(returnStdout: true, script: '''
                        Write-Host "Will there be a newline after me? " -NoNewLine
                        Write-Host "Yes! -> Unfortunately!"
                    ''')
                }
                script {
                    powershell(script: '''
                        Write-Host "Will there be a newline after me? " -NoNewLine
                        Write-Host "No! -> Great!"
                    ''')
                }
            }
        }
    }
}

 

 

peh@vizrt.com (JIRA)

unread,
Jun 17, 2019, 12:06:02 PM6/17/19
to jenkinsc...@googlegroups.com
Patrik Ehringer edited a comment on Bug JENKINS-56925
 

Maybe this is related...

The console output is different for the 2 scripts below - depending on if 'returnStdout: true' is used or not.
The second script does it right, the first - where 'returnStdout: true' is used - does it wrong.
I'm quite sure that the first script also worked correctly 2 months or so ago.


{code:java}

pipeline {
    agent any
    stages {
        stage('Test') {
            steps  {
                script {
                    stdo = powershell(returnStdout: true, script: '''
                     Write-Host "Will there be a newline after me? " -NoNewLine
                     Write-Host "Yes! -> Unfortunately!"
                    ''')
                }
                script {
                    powershell(script: '''
                     Write-Host "Will there be a newline after me? " -NoNewLine
                     Write-Host "No! -> Great!"
                    ''')
                }
            }
        }
    }
}

{code}
 
{noformat}
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Test)

[Pipeline] script
[Pipeline] {
[Pipeline] powershell
Will there be a newline after me?
Yes! -> Unfortunately!
[Pipeline] }
[Pipeline] // script
[Pipeline] script
[Pipeline] {
[Pipeline] powershell
Will there be a newline after me? No! -> Great!

[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS{noformat}
 

rostergek@gmail.com (JIRA)

unread,
Jun 25, 2019, 3:39:02 AM6/25/19
to jenkinsc...@googlegroups.com
gek edited a comment on Bug JENKINS-56925
But how?

Only way i see is use Write-Host -NoNewline , but it's output cannot be passed
throw thru :

 

[https://serverfault.com/questions/859826/output-is-truncated-in-jenkins-job-when-launching-powershell-script-remotely-usi]


 

For some reason Write-Host -NoNewline output cannot be assigned to variable.
Reply all
Reply to author
Forward
0 new messages