不要让 Jenkins 因 Git 发布者错误而失败

Don't fail Jenkins on Git Publisher errors

当 Jenkins 中的构建成功时,我使用 Git Publisher 插件推送到 GitHub。

每隔一段时间,github.com 推送超时,我在构建日志中有这个:

Pushing HEAD to branch develop at repo github
using GIT_SSH to set credentials 
 > git --version # timeout=10
 > git -c core.askpass=true push git@github.com:REPO.git HEAD:develop
ERROR: Failed to push branch develop to github
hudson.plugins.git.GitException: Command "git -c core.askpass=true push git@github.com:itext/itextpdf.git HEAD:develop" returned status code 128:
stdout: 
stderr: ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly

(Java stacktrace omitted)

Build step 'Git Publisher' marked build as failure

我不希望构建在推送到 github.com 不起作用时被标记为失败。 但是,我确实希望它被标记为不稳定。

原因:

我不希望个别开发人员担心 GitHub 的临时故障,这些问题通常在下次构建运行时无需干预即可解决。

除了将 Git Publisher 步骤拆分到另一个构建作业之外,我如何才能将构建结果从失败更改为不稳定?

我通过将作业分成两部分解决了这个问题:首先构建,在成功构建之后,开始一个推送到远程仓库的新作业。