exit-code

Jenkins - simply robocopy in Jenkins finishes marks build with failure

天涯浪子 提交于 2019-12-03 10:29:40
I have a simply windows batch command (robocopy) that returns zero errors but is always marked as a failure in Jenkins. I would like to know why? D:\Jenkins\jobs\Jenkins Config Backup\workspace>exit 1 Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE robocopy returns a bit map For details see here: http://ss64.com/nt/robocopy-exit.html In summary: All exit codes up to '3' are fine. This is the batch file code I usually use: set SOURCE= ... set DESTINATION= ... robocopy /MIR /LOG:example.robocopy.log.txt %SOURCE% %DESTINATION% @echo robocopy exit code:

Difference between Environment.Exit and simple return 2 from Main

烈酒焚心 提交于 2019-12-03 10:04:46
From outside of the application, is there any difference between ... Environment.Exit(2) and static int Main() { ... return 2; } ? The most obvious difference is that you can call Environment.Exit from anywhere in your code. Aside from that: Main finishing won't terminate the process if there are other foreground threads executing; Environment.Exit will take down the process anyway. Environment.Exit terminates the process without unwinding the stack and executing finally blocks (at least according to my experiments). Obviously when you return from Main you're already at the top level as far as

Can a batch file capture the exit codes of the commands it is invoking?

為{幸葍}努か 提交于 2019-12-03 09:45:28
Basically, let's say that I have a batch file that calls myapp1.exe and myapp1.exe exits with Exit Code 1. Can the batch file capture this information and either force the batch file to exit with that same exit code or perform some other logic? @echo off rem ... set errorlevel= MyApp1.exe exit /b %errorlevel% would be the explicit variant. You could try using errorlevel s. Some more info here . Nate Cook The accepted answer is correct, but if you are using call to call another batch script, and that second batch script is using SetLocal , you may need to use a parsing trick to accomplish this.

Customize zsh's prompt when displaying previous command exit code

旧城冷巷雨未停 提交于 2019-12-03 07:27:37
问题 Zsh includes the ability to display the return code/exit code of the previous command in the prompt by using the %? escape sequence. However I would like to have the following prompt: user@host ~ [%?] % when the exit code is different from 0 and: user@host ~ % when exit code is 0. If I use %? alone it is always displayed, even if %? is 0. In addition I want the square brackets but only when the exit code not 0. What is the simplest way to do this? 回答1: Add this in the position in PS1 where

How to bypass the 0-255 range limit for sys.exit() in python?

牧云@^-^@ 提交于 2019-12-03 07:09:46
In python (on a Linux system), I'm launching a command using os.system() and retrieving the return code. If that return code is different from 0, I would like to make the program exit with that same return code. So I wrote: ret = os.system(cmd) if ret != 0: print "exit with status %s" % ret sys.exit(ret) When the return code is lower than 256, it works fine, but when it's greater than 255, the exit code used is 0. How can I make sys.exit() accept codes greater than 255? Edit: the limit is actually 255 In fact, the ret variable receives 256, but sys.exit() fails to use it, so the program

Run MsiExec from PowerShell and get Return Code

99封情书 提交于 2019-12-03 05:38:06
问题 With BAT/CMD script I can simply use "msiexec /i <whatever.msi> /quiet /norestart" and then check %errorlevel% for the result. With VBScript , using the Wscript.Shell object Run() method, I can get the result like this: "result = oShell.Run("msiexec /i ...", 1, True)" How can I do this with PowerShell? 回答1: I would wrap that up in Start-Process and use the ExitCode property of the resulting process object. For example (Start-Process -FilePath "msiexec.exe" -ArgumentList "<<whatever>>" -Wait

How to trap exit code in Bash script

爷,独闯天下 提交于 2019-12-03 05:30:37
问题 There're many exit points in my bash code. I need to do some clean up work on exit, so I used trap to add a callback for exit like this: trap "mycleanup" EXIT The problem is there're different exit codes, I need to do corresponding cleanup works. Can I get exit code in mycleanup? 回答1: I think you can use $? to get the exit code. 回答2: The accepted answer is basically correct, I just want to clarify things. The following example works well: #!/bin/bash cleanup() { rv=$? rm -rf "$tmpdir" exit

Is it possible to get the exit code from a subshell?

亡梦爱人 提交于 2019-12-03 04:31:08
Let's imagine I have a bash script, where I call this: bash -c "some_command" do something with code of some_command here Is it possible to obtain the code of some_command ? I'm not executing some_command directly in the shell running the script because I don't want to alter it's environment. Matti Virkkunen $? will contain the return code of some_command just as usual. Of course it might also contain a code from bash, in case something went wrong before your command could even be executed (wrong filename, whatnot). Dennis Williamson Here's an illustration of $? and the parenthesis subshell

What is the meaning of values from Java Process.exitValue()?

丶灬走出姿态 提交于 2019-12-03 03:40:00
I am using Process via ProcessBuilder to run an executable made in C code. I am catching the Process.exitValue() to react on this exit values. I noticed not all the exit values are from the executable. For example, I get an exit value of 139 and nowhere in my C code I am returning an exit value of 139. I am trying to find an overview of exit values, but I cannot find this, and now I found out the exit value can be OS dependent. (I am using Ubuntu by the way). It seems the only exit value to be sure of is 0 when everything goes right. Are there specifications about exit values? Can I be sure

Customize zsh's prompt when displaying previous command exit code

点点圈 提交于 2019-12-02 20:08:58
Zsh includes the ability to display the return code/exit code of the previous command in the prompt by using the %? escape sequence. However I would like to have the following prompt: user@host ~ [%?] % when the exit code is different from 0 and: user@host ~ % when exit code is 0. If I use %? alone it is always displayed, even if %? is 0. In addition I want the square brackets but only when the exit code not 0. What is the simplest way to do this? Add this in the position in PS1 where you want the exit code to appear: %(?..[%?] ) It's a conditional expression. The part between the two dots