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

Add skipSave parameter #214

Merged
merged 1 commit into from
Jul 16, 2023

Conversation

andrewradamis-paay
Copy link
Contributor

@andrewradamis-paay andrewradamis-paay commented Jul 11, 2023

Add skipSave parameter. When set to true, this will skip updating the cache at the end of the step. This is useful to me in a pipeline I'm working on where I'm using this plugin for both caching and moving files between nodes. A simplified example below.

Additionally, this change should resolve #150

pipeline {
    agent 'build'

    stages {
        stage('Init') {
            steps {
                echo 'Initialize Terraform'
                cache(caches: [arbitraryFileCache(cacheName: "dot_terraform", path: '.terraform/')]) {
                    sh(script: 'terraform init -backend=false') // Initialize Terraform without backend configuration, downloads providers, modules, etc
                }
            }
        }
        stage('Deploy to Multiple Regions') {
            parallel {
                stage('us-east-1') {
                    agent {
                        label 'us-east-1'
                    }
                    steps {
                        cache(skipSave: true, caches: [arbitraryFileCache(cacheName: "dot_terraform", path: '.terraform/')]) {
                            sh(script: 'terraform init') // plan, deploy, etc
                        }
                    }
                }
                stage('us-west-2') {
                    agent {
                        label 'us-west-2'
                    }
                    steps {
                        cache(skipSave: true, caches: [arbitraryFileCache(cacheName: "dot_terraform", path: '.terraform/')]) {
                            sh(script: 'terraform init') // plan, deploy, etc
                        }
                    }
                }
            }
        }
    }
}

Testing done

I've added a basic unit test for this change, as well as tested it manually.

Submitter checklist

@andrewradamis-paay andrewradamis-paay requested a review from a team as a code owner July 11, 2023 16:20
@repolevedavaj repolevedavaj merged commit 12d4fad into jenkinsci:main Jul 16, 2023
14 checks passed
@repolevedavaj
Copy link
Contributor

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to disable cache creation
2 participants