Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

[RFE] Implement a smart teardown for the pipelines #1662

Open
rplevka opened this issue Nov 11, 2019 · 0 comments
Open

[RFE] Implement a smart teardown for the pipelines #1662

rplevka opened this issue Nov 11, 2019 · 0 comments

Comments

@rplevka
Copy link
Member

rplevka commented Nov 11, 2019

Currently, the pipeline post section executed on failure tries perform several actions (spanning from archiving the artifacts to destroying the domain) not taking into account the stage it failed on.

This usually causes another failures being raised during the teardown itself, making the failure root cause being buried under a lot of unnecessary logs and failure messages.

If we could keep track of the pipeline progress, e.g. by keeping a simple stage number flag, we could use this var during the teardown to identify only the applicable teardown steps.

e.g.

/* this is just a pseudo-code, don't expect it to be functional, it's just to demonstrate the logic */
stage('create vm'){
 recent_stage = 0;
 ..stage code...
}
stage('install katello'){
 recent_stage = 1;
  ..stage code...
}
stage('run tests'){
 recent_stage = 2;
  ..stage code...
}
stage('run something else'){
 recent_stage = 3;
  ..stage code...
}

post {
  failure {
    teardown_steps = ['destroy_vm', 'archive_artifacts', 'something_else'];
    if(recent_stage > 0){
      for(i=teardown_steps.size - recent_stage; i < teardown_steps.size; i++){
        println(teardown_steps.reverse()[i]);
        eval(teardown_steps[-i]);
        }
      } 
    }
  }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant