有没有办法在声明性 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?
例如:
pre {
always {
rm -rf ./*
}
}
这将在签出源代码之前清理我的构建工作区.
This would then clean the workspace of my build before the source code is checked out.
推荐答案
pre
是一个很酷的功能想法,但还不存在.skipDefaultCheckout
和 checkout scm
(与默认 checkout 相同)是键:
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屋!
查看全文