[JIRA] [workflow-plugin] (JENKINS-26133) Shell script taking/returning output/status

2016-05-19 Thread pw...@cloudbees.com (JIRA)
Title: Message Title
 
 
 
 
 
 
 
 
 
 
  
 
 Patrick Wolf updated an issue 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 Jenkins /  JENKINS-26133 
 
 
 
  Shell script taking/returning output/status  
 
 
 
 
 
 
 
 
 

Change By:
 
 Patrick Wolf 
 
 
 

Labels:
 
 api  followup 
 
 
 
 
 
 
 
 
 
 
 
 

 
 Add Comment 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 

 This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265) 
 
 
 
 
  
 
 
 
 
 
 
 
 
   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] [workflow-plugin] (JENKINS-26133) Shell script taking/returning output/status

2015-08-20 Thread jgl...@cloudbees.com (JIRA)
Title: Message Title
 
 
 
 
 
 
 
 
 
 
  
 
 Jesse Glick commented on  JENKINS-26133 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
  Re: Shell script taking/returning output/status  
 
 
 
 
 
 
 
 
 
 
Capture of exit status as a return value can be handled directly in DurableTaskStep.Execution, by simply returning Integer rather than returning void or throwing AbortException. 
Capture of standard output is a little trickier because we would like to continue to direct standard error to the build log, and durable-task controllers currently mix them in the same stream. The API likely needs to be changed so that when launching the process you can request separate streams. (jenkins-out.txt vs. jenkins-err.txt I suppose, and two log position fields.) DurableTaskStep.Execution could then maintain a ByteArrayOutputStream-like buffer (but Serializable) collecting the output to be returned. Alternately, the controller could just return the complete standard output when the process exits, alongside the status code, which would make for a simpler API change, under the assumption that future clients do not want to stream output. 
Likewise, sending standard input would require an API addition in durable-task. Streaming the input would be very awkward for a durable task (providing an InputStream is not possible) so you would probably have to provide the byte[] content up front. 
Both API changes could potentially be avoided by just making DurableTaskStep.Execution modify the script to use redirects as shown in the workarounds here, using a random temporary file. There are some tricky parts here, too, though: the file ought to be outside the workspace to avoid clashes with scripts which expect to “own” the whole directory tree (cf. discussion in JENKINS-27152); and to handle multiline scripts, or even scripts with shebangs (#!/usr/bin/python), you really need to save the user-provided script into another temporary file, then do a little dance to make it into a complete executable that could be called from the redirecting wrapper script (and here cf. JENKINS-29877). 
Useful also for bat. According to answers here, Bourne shell syntax works for batch scripts too. 
 
 
 
 
 
 
 
 
 
 
 
 

 
 Add Comment 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 

 This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265) 
 
 
 
 
  
 
 

[JIRA] [workflow-plugin] (JENKINS-26133) Shell script taking/returning output/status

2014-12-17 Thread jgl...@cloudbees.com (JIRA)














































Jesse Glick
 created  JENKINS-26133


Shell script taking/returning output/status















Issue Type:


Improvement



Assignee:


Jesse Glick



Components:


workflow-plugin



Created:


17/Dec/14 5:21 PM



Description:


Currently sh has no meaningful return value, and throws an exception if the exit status is not zero. Would be nice to have an option to have it return the exit code (zero or not) as an integer value:


def r = sh script: 'someCommand', returnStatus: true


Current workaround:


sh 'someCommand; echo $? > status'
def r = readFile('status').trim()


Or to have it return its standard output (akin to shell backticks):


def lines = sh(script: 'dumpStuff.sh', returnStdout: true).split("\r?\n")


Workaround:


sh 'dumpStuff.sh > result'
def lines = readFile('result').split("\r?\n")


Or to have it take something on standard input:


sh script: 'loadStuff.sh', stdin: someText


Workaround:


writeFile file: 'input', text: someText
sh 'loadStuff.sh < input'


Probably requires some API changes in durable-task.




Project:


Jenkins



Labels:


api




Priority:


Major



Reporter:


Jesse Glick

























This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira







-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.