Created
July 28, 2020 17:18
-
-
Save rgoomar/cff13422c0808cd3f6a73146ac2a9288 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!groovy | |
| pipeline { | |
| stages { | |
| stage('Check for CHANGELOG update') { | |
| when { expression { env.BRANCH_NAME != 'master' } } | |
| steps { | |
| script { | |
| sshagent(['CREDENTIAL_NAME']) { | |
| sh "git config --add remote.origin.fetch +refs/heads/master:refs/remotes/origin/master" | |
| sh "git fetch --no-tags" | |
| List<String> sourceChanged = sh(returnStdout: true, script: "git diff --name-only origin/master..origin/$").split() | |
| def isSourceChanged = false | |
| def isChangelogUpdated = false | |
| for (int i = 0; i < sourceChanged.size(); i++) { | |
| if (sourceChanged[i].contains("src")) { | |
| isSourceChanged = true | |
| } | |
| if (sourceChanged[i].contains("CHANGELOG")) { | |
| isChangelogUpdated = true | |
| } | |
| } | |
| // Changelog not updated after changing source, fail build and notify | |
| if (isSourceChanged && !isChangelogUpdated) { | |
| error("Source files changed but CHANGELOG was not updated!") | |
| } | |
| } | |
| } | |
| } | |
| post { | |
| failure { | |
| // post to Slack | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment