gpt4 book ai didi

jenkins - 如何在 check out Jenkinsfile 中的存储库之前清理管道

转载 作者:行者123 更新时间:2023-12-04 14:15:07 25 4
gpt4 key购买 nike

我想做一个 clean before checkout Jenkins git plugin documentation 中描述的操作:

Clean before checkout Clean the workspace before every checkout by deleting all untracked files and directories, including those which are specified in .gitignore. ...



但是如何将此选项添加到作为第一步的默认结帐步骤?

我觉得它应该是 git 插件扩展的一个选项,可以包含到 options Jenkinsfile 块,如 docs 中所述:

The options directive allows configuring Pipeline-specific options from within the Pipeline itself. Pipeline provides a number of these options, such as buildDiscarder, but they may also be provided by plugins...



但是如何知道该插件提供了哪些选项及其名称?没有在文档中找到它,我也可能错了 clean before checkout应该放在 options Jenkinsfile 块。

请帮忙。

最佳答案

正如评论中已经提到的,要走的路是使用 skipDefaultCheckout() ( Source ) 在您的管道选项中,以便在管道启动时不 check out 存储库。

skipDefaultCheckout

Skip checking out code from source control by default in the agent directive.



要手动获取存储库,您可以使用 checkout scm ( Source )
pipeline {
agent any
options {
skipDefaultCheckout()
}
stages {
stage('Example') {
steps {
// Cleanup before starting the stage
// deleteDir() / cleanWs() or your own way of cleaning up

// Checkout the repository
checkout scm

// do whatever you like
}
}
}
}

关于jenkins - 如何在 check out Jenkinsfile 中的存储库之前清理管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60958037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com