Last active
April 16, 2021 22:35
-
-
Save beatngu13/113eed1f208c3199a3aeae979b408fd1 to your computer and use it in GitHub Desktop.
Cron-triggered Jenkins pipeline to send patches via email on available Maven dependency updates
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
pipeline { | |
agent any | |
triggers { | |
cron('00 23 * * 1-5') | |
} | |
stages { | |
stage('Check dependency updates') { | |
steps { | |
script { | |
String filename = 'dependency-updates.patch' | |
String script = """ | |
mvn versions:use-latest-versions -B -U -DgenerateBackupPoms=false | |
git diff --unified=0 --exit-code pom.xml > ${filename} | |
""" | |
int exitCode = sh script: script, returnStatus: true | |
if (exitCode == 1) { | |
emailext subject: 'Dependency updates available', | |
body: "See attached patch: ${filename}", | |
attachmentsPattern: "**/${filename}", | |
to: '[email protected], [email protected]' | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Maven Version Plugin is a beast! Also check out its other goals such as
versions:update-properties
to update your properties.