Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

changeset in jenkins pipeline

stage ("Deploy branches") {
    agent any

    when { 
        allOf {
            not { branch 'master' }
            changeset "some-directory/**"
            expression {  // there are changes in some-directory/...
                sh(returnStatus: true, script: 'git diff  origin/master --name-only | grep --quiet "^some-directory/.*"') == 0
            }
            expression {   // ...and nowhere else.
                sh(returnStatus: true, script: 'git diff origin/master --name-only | grep --quiet --invert-match "^some-directory/.*"') == 1
            }
        }
    }

    steps {
        // do stuff
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #changeset #jenkins #pipeline
ADD COMMENT
Topic
Name
7+7 =