简体   繁体   中英

Execute shell command in Jenkins does not recognize the pipe character

In the Execute shell command option in Jenkins I am trying to execute xcodebuild -scheme "My project" test | xcpretty --report junit --output report.xml

But when Jenkins executes it, it looks like it does not recognize the pipe character and it takes it as next line or something.

Things I have tried - Putting the command in a .sh file - Escaping the pipe character - Use Eval

None of them have worked

I do not want to use the Xcode plugin for the moment.

Any tips to make it work?

Try putting #!/bin/bash at the top of your command-line code. (Please don't make the wrong spelling.)

EDIT: If it is not the pipe, then it could be that you need to take the output of the first command and wrap it so it sends it all at once... I might be wording that wrong.

OUT="$(xcodebuild -scheme "My project" test)"
echo $OUT | xcpretty --report junit --output report.xml

It looks like it's treating it as a newline because both commands are actually being executed at the same time; they are not executed sequentially. See What is a simple explanation for how pipes work in Bash?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM