A way to make Jenkins ignore stderr?

I have a jenkins ci job that runs some shell (linux) commands. Specifically, I connect to a git repository and use git to add remote access to make sure the remote is installed before running other commands. Typically, the remote is still there and there is stderr output saying "fatal: remote foo already exists" which is fine for me, but mr. Jenkins stops the assignment and marks it as failed.

How can I tell Jenkins to ignore this stderr or what was he expecting? Or is there a smarter approach to this?

Thanks in advance.


source to share

2 answers

git add remote git_repo || true


this will return exit status 0



The problem is that Jenkins looks at exit codes and the build fails if any of the targets you run return a non-zero exit code. So ignoring STDERR won't help. Infact this is probably bad because any real glitches elsewhere will not show up in Jenkins logs if you hide STDERR.

the git command you run returns 1 if the remote already exists. The work around is to wrap the git command and ignore the exit value and return your own exit value instead



All Articles