Skip to content

Instantly share code, notes, and snippets.

@nguyenthang98
Last active September 21, 2020 15:21
Show Gist options
  • Select an option

  • Save nguyenthang98/dcc9a8a203d1c6a233cab6479c3bb755 to your computer and use it in GitHub Desktop.

Select an option

Save nguyenthang98/dcc9a8a203d1c6a233cab6479c3bb755 to your computer and use it in GitHub Desktop.
git extract information
#!/bin/bash
change_files="$(git diff --name-only HEAD HEAD~1 | xargs echo)"
test_files=$@
for file in $test_files; do
if [[ $change_files =~ (^|[[:space:]])"$file"($|[[:space:]]) ]]; then
echo "contain file $file"
else
echo "not contain file $file"
fi
done
# view file changed in latest merge from last merge
git log --merges --format="%H %ae"| head -n 2 | awk '{print $1}' | xargs git diff --name-only $1 $2
post {
success {
script {
def merger_email = sh returnStdout: true, script: ' git log --merges -n 1 --format=%ae'
def commiter_email = sh returnStdout: true, script: ' git log --no-merges -n 1 --format=%ae'
mail bcc: '', subject: "Jenkins Job ${env.JOB_NAME}-${env.BUILD_DISPLAY_NAME} success", cc: commiter_email, from: '', replyTo: '', body: "Jenkin Build Success. Check it out: ${env.BUILD_URL}", to: merger_email
}
}
cleanup {
deleteDir()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment