【发布时间】:2020-12-19 18:45:01
【问题描述】:
我正在尝试将 Job 动态加载到 Jenkins,有一个包含 Job Name 和 GHE URL 的文件:
GHE 文件网址:
options A
https://github.com/I/A/build.groovy
options B
https://github.com/I/B/build.groovy
options C
https://github.com/I/C/build.groovy
使用下面的 bash 脚本,我可以创建一个新的 Repo (A,B,C) 目录并在管道 scm 中使用 GHE URL,我如何在 groovy dsl 中实现这一点:
while read -r line; do
case "$line" in
options*)
jenkins_dir=$(echo "$line" | cut -d ' ')
mkdir -p ${jenkins_dir}
;;
http://github*)
wget -N $line -P ${jenkins_dir}
;;
*)
echo "$line"
;;
esac
done < jenkins-ghe.urls
Groovy DSL 版本:
def String[] loadJobURL(String basePath) {
def url = []
new File('/path/to/file').eachLine { line ->
switch("$line") {
case "options*)":
case "http://github*)":
}
有几个失败,不太确定 groovy dsl 的语法,希望 dsl 脚本能够识别这两行。请推荐,谢谢!
【问题讨论】: