I can't get anything to work with bat in pipeline jenkinsfile

11 views
Skip to first unread message

wowberk

unread,
Mar 27, 2020, 8:40:24 AM3/27/20
to Jenkins Users
Hi all, 

I have uploaded this file.jenkinsfile in a repository

pipeline {
agent any
options {
timeout(4)
}


stages {
stage('SmokeTest Login') {
steps {
sleep 15
echo 'SmokeTest Login Init..'
bat returnStdout: true, script: 'echo %PATH%'
echo 'SmokeTest Login Finished..'
}
}
}


but i can't get jenkins to return anything on screen or continue or showing any kind of error.


[Pipeline] {
[Pipeline] stage
[Pipeline] { (SmokeTest Login)
[Pipeline] sleep
Sleeping for 15 sec
[Pipeline] echo
SmokeTest Login Init..
[Pipeline] bat
Cancelling nested steps due to timeout
Sending interrupt signal to process
After 20s process did not stop
[Pipeline] }

Daniel Butler

unread,
Mar 27, 2020, 9:09:55 AM3/27/20
to jenkins...@googlegroups.com
If you want to see the bat file output, remove the returnStdOut. You only need that if you want to assign the output to variable and use it later in the pipeline.
if you still want it in the logging as well as a variable:

output = bat returnStdout: true, script: 'echo %PATH%'



--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c70ebdda-42ab-4a85-83ea-f6c711cd7f4b%40googlegroups.com.

Daniel Butler

unread,
Mar 27, 2020, 9:10:40 AM3/27/20
to jenkins...@googlegroups.com
in the code snippet it should have had a second line:

echo output

wowberk

unread,
Mar 27, 2020, 9:39:56 AM3/27/20
to Jenkins Users
Sorry, but with:

output = bat returnStdout: true, script: 'echo %PATH%'
echo output

return 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 15: Expected a step @ line 15, column 17.
                   output = bat returnStdout: true, script: 'echo %PATH%'
                   ^
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.

wowberk

unread,
Mar 27, 2020, 11:12:42 AM3/27/20
to Jenkins Users
Solved by changing job type.
Reply all
Reply to author
Forward
0 new messages