Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
349 views
in Technique[技术] by (71.8m points)

Jenkins advanced abort previous builds

I have a very specific 'problem' with our Jenkins builds. We have a Jenkins declarative pipeline set up for our projects, the pipeline contains all stages needed for automated testing, releases, ... However, we would like to avoid unnecessary builds and thus we would want to cancel older builds if a new commit was done on a branch. We already investigated the milestone approach but this wasn't enough for us (as far as we see). I'll show the problem with an example:

Let's say build 1 starts of a PR, these are the steps it will take:

  1. Build the code
  2. Take a snapshot of our test environment
  3. Deploy the code to our test environment
  4. Run all tests
  5. Restore previously taken snapshot
  6. Some other steps

With the milestone approach, you have no idea where in the pipeline the older build will get aborted. So, continuing the example:

Let's now say build 2 starts of the PR, and build 1 was in step 4: Possible problem: snapshot isn't restored (but I think we can fix that by catching the abort exception) Let's now say build 2 starts when build 1 is in step 5: Problem: we don't know where in the restore process the build is aborted, so our environment could get corrupted!

So, to conclude: I am looking for a way to either say: from this point on, this build can't be aborted by milestones. Or to 'disable' the milestone aborts for a while, so that build 1 will always finish the snapshot restore before being aborted.

question from:https://stackoverflow.com/questions/65883159/jenkins-advanced-abort-previous-builds

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...