如何在工作开始前清除 Jenkins 管道中的工作区 [英] How to clear workspace in Jenkins pipeline before job starts

查看:18
本文介绍了如何在工作开始前清除 Jenkins 管道中的工作区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在构建开始之前清除工作区.我尝试分阶段使用 cleanDir() ,但是在声明性管道中,首先发生签出,当带有 cleadDir 的阶段运行时,签出的代码也会被清除,这是不需要的.我们如何在声明式管道中签出之前清除工作区?

I need to clear workspace before build starts. I tried using cleanDir() in stages, but in the declarative pipeline, check out happens first and when stage with cleadDir runs, checked out code also gets cleared which is not desired. How can we clear the workspace before check out in the declarative pipeline?

推荐答案

使用你的 VCS 的方法,用 Git 运行

Use the means of your VCS, with Git run

git clean -fdx

这篇关于如何在工作开始前清除 Jenkins 管道中的工作区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆