git - 有没有在詹金斯管道常规脚本中调用 git clean 的正确方法?
问题描述
我不想使用checkout scm
,这就是我问的原因。我想检查 jenkinsfile 中的多个存储库并确保工作区是干净的(git clean)
因为checkout scm
有一个复选框可以做到这一点。如何在 groovy 中为 git checkout 功能重现这个?我发现关于这个主题的所有内容都是git clean -fdx
通过 shell 调用进行调用,但如果可能的话,我更喜欢 groovy 中的干净解决方案而不是 shell 调用。
def checkoutGit(def cred,def repo, def branch)
{
git credentialsId: cred, url: repo, branch: branch
}
类似于此处描述的内容:https: //support.cloudbees.com/hc/en-us/articles/226122247-How-to-customize-Checkout-for-Pipeline-Multibranch
node {
checkout([
$class: 'GitSCM',
branches: scm.branches,
extensions: scm.extensions + [[$class: 'CleanCheckout']],
userRemoteConfigs: scm.userRemoteConfigs
])
//Build, Test, Stage, Deploy
[...]
}
但不是用于结帐,而是用于 git 功能。(见上面的例子)
解决方案
git step 方法功能是在插件方法中指定为参数的GitSCM类的子集。如果您无法通过类实现功能,那么在 step 方法中也是不可能的。workflow-scm-step
checkout
在这种情况下,step 方法的文档确认无法进行清洁。checkout
如问题中所述,只有在您想使用 Groovy 绑定到 Git 时才能进行清理。因此,在您的情况下,您确实必须git clean -fdx
在 shell step 方法中使用所需的功能。
推荐阅读
- reactjs - 无法获取 Firebase 存储文件
- apache-flink - 如何使用 flink cep 完成聚合任务
- html - 如何填充css网格中剩余的空列
- javascript - 我不知道如何在反应中定义 state 和 this.setState
- javascript - 用javascript显示多张图片
- java - 如何修复 httpclient tls unknow_certificate 错误?
- python - 绘制时间太近
- android - 启用禁用并在android中选中的自定义复选框
- pandas - pandas groupby on year, month for mean 给出了年月的空白值
- python - 如何将网页上的所有文本抓取到 python 中的特定标题?