Groovy DSL比较字符串

问题描述

我正在尝试将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*)":
           
}

有一些失败,不是很清楚wrt groovy dsl的语法,而是希望dsl脚本识别这两行。请建议,谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)