在 Jenkins 上列出更改数据

问题描述 投票:0回答:1

我有一个 Jenkins 管道,列出了如下的回购更改;

问题是我不知道如何“更改”添加到管道中的数据。

我想使用声明性脚本将相同的数据添加到新管道。

知道我该怎么做吗?使用插件或脚本?

jenkins jenkins-pipeline jenkins-plugins
1个回答
0
投票

您可以在 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}"
                    }
                }
            }
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.