Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Declarative-style pipeline to support "rollbacks" through "Restart from Stage" functionality #42

Closed
kmanning opened this issue Sep 3, 2019 · 0 comments

Comments

@kmanning
Copy link
Collaborator

kmanning commented Sep 3, 2019

  • Rewrite the underlying pipeline to use the Declarative Pipeline style.

DeclarativePipelines are much more strict than scripted. You can't arbitrarily execute code within stages() to dynamically generate stages.

  • when running on non-master, the confirm/apply stages are intentionally skipped. DeclarativePipelines make this difficult. We'd have to render the entire pipeline with confirm/apply on master, and render the entire pipeline with on non-master.
  • stages are currently nested, with around hooks. The plugin infrastructure will need to be rethought a little. around-all may need to mean applying an around to each individual stage.
    • this means rethinking the CrqPlugin, FileEnvironmentPropertiesPlugin, ConditionalApplyPlugin.

DeclarativePipelines are an enormous pain.

  • Variable names cannot be used in Declarative PIpeline stages (See: https://issues.jenkins-ci.org/browse/JENKINS-43820)
  • We cannot use Groovy.eval to dynamically generate a declarative pipeline
  • For some reason, you lose the ability to even create a declarative pipeline, once you assign this to a variable. Eg:
def Jenkinsfile = this
Jenkinsfile.pipeline {

} // This immediately triggers a Scripted Pipeline, altering what is considered valid syntax

The best compromise that I can think of:

  1. Create a series of declarative pipeline "templates". A template defines a fixed number of stages. Each stage in the template is named "1", "2", "3", etc.
  2. In terraform-pipeline, at the time of build(), count the number of Stages that the user has created. Pick the corresponding template that has exactly that many stages.
  3. In each template stage, embed the corresponding terraform-pipeline stage, within a script block.
  4. This solves the underlying problem of allowing entire environments to be Re-Run. This is also a terrible solution - the Declarative Pipeline syntax is simply too restrictive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant