我正在探索Jenkins 2.0管道。到目前为止,我的文件非常简单。
node {
stage "checkout"
git([url:"https://github.com/luxengine/math.git"])
stage "build"
echo "Building from pipeline"
}
我似乎找不到任何方法来设置git将 check out 的目录。我也找不到与此有关的任何文档。我找到了 https://jenkinsci.github.io/job-dsl-plugin/,但似乎与其他教程中看到的不匹配。
请您参考如下方法:
澄清度
看起来您正在尝试配置Pipeline作业(以前称为Workflow)。这种工作与Job DSL非常不同。
管道作业的目的是:
Orchestrates long-running activities that can span multiple build slaves. Suitable for building pipelines (formerly known as workflows) and/or organizing complex activities that do not easily fit in free-style job type.
作为Job DSL:
...allows the programmatic creation of projects using a DSL. Pushing job creation into a script allows you to automate and standardize your Jenkins installation, unlike anything possible before.
解
如果要将代码 check out 到特定目录,则将
git步骤替换为更通用的SCM
checkout步骤。
最终的 Pipeline配置应如下所示:
node {
stage "checkout"
//git([url:"https://github.com/luxengine/math.git"])
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory',
relativeTargetDir: 'checkout-directory']],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/luxengine/math.git']]])
stage "build"
echo "Building from pipeline"
}
作为 Jenkins 2.0和 Pipeline DSL的将来引用,请使用内置的Snippet Generator或 documentation。


