Home > Net >  Jenkins build from workspace if Git is unavailable
Jenkins build from workspace if Git is unavailable

Time:09-23

We're running a number of periodic jobs on a schedule and if Git is not available due to maintenance or an outage (clones from an on-network Github Enterprise instance), the jobs fail. Is there any way to configure jobs so that they can build from the existing workspace if Git is down or inaccessible? Thanks!

CodePudding user response:

The first step is to make sure your periodic job does not cleanup the workspace after its build.

Second, split your pipeline into two stages:

  • one for the git ls-remote, followed by, if it works, a workspace cleanup and a clone: you can also use try catch if the ls-remote fails, meaning the remote is not available: log a warning, and move on the the second stage
  • one for the job itself
  • Related