有没有办法在声明性Jenkins管道中运行预结帐步骤? [英] Is there a way to run a pre-checkout step in declarative Jenkins pipelines?
本文介绍了有没有办法在声明性Jenkins管道中运行预结帐步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Jenkins声明性管道为 post 指令提供了在阶段结束后执行代码 .在阶段运行之前,并且最重要的是在SCM结帐之前,是否有类似的事情要运行代码 ?
Jenkins declarative pipelines offer a post directive to execute code after the stages have finished. Is there a similar thing to run code before the stages are running, and most importantly, before the SCM checkout?
例如,类似以下内容的东西:
For example something along the lines of:
pre {
always {
rm -rf ./*
}
}
这将在检出源代码之前清理构建的工作空间.
This would then clean the workspace of my build before the source code is checked out.
推荐答案
pre
是一个很棒的功能,但尚不存在. skipDefaultCheckout
和checkout scm
(与默认结帐相同)是键:
pre
is a cool feature idea, but doesn't exist yet. skipDefaultCheckout
and checkout scm
(which is the same as the default checkout) are the keys:
pipeline {
agent { label 'docker' }
options {
skipDefaultCheckout true
}
stages {
stage('clean_workspace_and_checkout_source') {
steps {
deleteDir()
checkout scm
}
}
stage('build') {
steps {
echo 'i build therefore i am'
}
}
}
}
这篇关于有没有办法在声明性Jenkins管道中运行预结帐步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文