简体   繁体   中英

How to re-trigger a stage in a Jenkinsfile

I have a situation where in 2 Stages in a Jenkinsfile I have to do the following things:

  1. Push a Docker image to artifactory . This push is to a folder on artifactory where I cannot delete that pushed image easily (a lot of process is involved to get that deleted).
  2. Committing/ Merging changes to the master repo on GitLab , within the stage itself (and not through an MR).

These 2 stages are connected to each other ie if Stage 1 has executed, then Stage 2 has to be executed.

So, you can understand these 2 stages are critical as in, they are making almost permanent changes to main folders and repos.

  1. If Stage 1 fails (due to random flaky or connectivity issues), we want to re-run stage 1, and then continue with the job to stage 2
  2. Also if Stage 1 has been executed successfully, but Stage 2 has failed, then I only want to run Stage 2 again.

Can someone suggest what can be done for this?

For Declarative jobs, if you want to run stage 2 after stage 1 ran and the whole job failed, you can go to the specific build page and use the option "Restart From Stage". from here :

Once your Pipeline has completed, whether it succeeds or fails, you can go to the side panel for the run in the classic UI and click on "Restart from Stage".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM