【问题标题】:Is there a way to stop changes to certain file types invalidating a successful build?有没有办法阻止对某些文件类型的更改使成功构建无效?
【发布时间】:2021-05-17 16:19:34
【问题描述】:

例如,如果我更改 .md 文件,我希望不必重新运行构建。我的文档更改不会破坏构建。

【问题讨论】:

  • 你的持续集成系统是什么?詹金斯?
  • 是的,詹金斯。 ....

标签: bitbucket-server


【解决方案1】:

这是解决方案。它可能需要更改安全性(对于getPreviousBuild 脚本)。目前还没有完全测试,如果有变化我会更新。

这将检查提交是否包含任何不是.md 文件的文件,如果最后一次构建成功,则运行构建或传递构建。

  stage('Check for doc only commit') {
            environment {
                LAST_BUILD = currentBuild.rawBuild.getPreviousBuild()
            }
            steps {
                script {
                    if (LAST_BUILD && LAST_BUILD.getResult().toString() == "SUCCESS") {
                        echo "the previous build ${LAST_BUILD.getId()} passed, checking for a docs-only commit"
                        NON_DOC_COUNT = sh(
                                script: 'git show --pretty="format:" --name-only | grep -v -e \'.md\' | wc -l',
                                returnStdout: true
                        ).trim()
                        if (NON_DOC_COUNT.toInteger() == 0) {
                            echo "Found no non-document files in the last commit and previous build was a pass, returning success result"
                            currentBuild.result = 'SUCCESS'
                            return
                        }
                    }
                }
            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-11
    • 1970-01-01
    • 2021-10-29
    • 1970-01-01
    • 2013-07-22
    • 2012-05-08
    相关资源
    最近更新 更多