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

Declarative Pipeline - Support preserveStages to enable "Restart from Stage" #218

Closed
sujikann opened this issue May 8, 2020 · 0 comments · Fixed by #240
Closed

Declarative Pipeline - Support preserveStages to enable "Restart from Stage" #218

sujikann opened this issue May 8, 2020 · 0 comments · Fixed by #240
Labels
enhancement New feature or request
Milestone

Comments

@sujikann
Copy link

sujikann commented May 8, 2020

Overview

The terraform-pipeline supports setting up a Declarative pipeline. Declarative pipelines give us the advantage of restarting pipeline from a stage from a previous run. "Restart from Stage" requires the stash artifact to be available to use in a subsequent stage.
With terraform-pipeline, the Restart from stage does not work since the artifact is not stashed and preserved for a future run. Jenkins pipeline library requires "preserveStashes" option setup in order for "Restart from stage" to work.

Ref: https://www.jenkins.io/doc/book/pipeline/syntax/

preserveStashes
Preserve stashes from completed builds, for use with stage restarting. For example: options {
preserveStashes() } to preserve the stashes from the most recent completed build, or options
{ preserveStashes(buildCount: 5) } to preserve the stashes from the five most recent completed builds.

Workaround

terraform-pipeline/vars/Pipeline5Stage.groovy
Add options { preserveStashes() }

Or use a CustomPipelineTemplate to override the pipeline

pipeline {
     agent {
         node {
             label ''
         }
     }

     options { preserveStashes() }
     stages {
         stage('Validate') {
             steps {
                 script {
                     validate.build()
                 }
             }
         }
 
         stage('Build Artifact') {
             steps {
                 script {
                     buildArtifact.build()
                 }
             }
         }
  }

@kmanning kmanning added this to the v5.8 milestone May 29, 2020
@kmanning kmanning added the enhancement New feature or request label May 29, 2020
@kmanning kmanning linked a pull request Jul 9, 2020 that will close this issue
@kmanning kmanning closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants