您可以在 Jenkinsfile 中使用以下内容:
pipeline {
agent any
stages {
stage('Checkout') {
steps {
// This step checks out the SCM and automatically logs changes
checkout scm
}
}
// Other stages for building/testing/deploying
}
post {
success {
script {
// You can add a script here to do something with the change log
def changeLogSets = currentBuild.changeSets
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
echo "${entry.commitId} by ${entry.author} on ${entry.date}: ${entry.msg}"
}
}
}
}
}
}