2017-09-25 44 views
0

我有一个hidden parameterJenkins调用platformType。我想根据参数platformType显示选项。我创建了以下Groovy脚本,但它不工作Jenkins活动选择参数插件不按预期方式工作

if (platformType.equals("android")) { 
    return ['7.0', '6.0'] 
} else (platformType.equals("ios")) { 
    return ['10.0', '9.0'] 
} 

请参见下面的 enter image description here

回答

1

截图肯定你没有指定platformType作为参数传递给platformVersion或者你有其他错误的代码..

没有错误处理,你只是没有看到它。

在你的脚本,你可以赶上像这样的例外:在这种情况下

try { 
    if (platformType.equals("android")) { 
     return ['7.0', '6.0'] 
    } else if(platformType.equals("ios")) { 
     return ['10.0', '9.0'] 
    } 
}catch(e){ return [e.toString()] } 

你会看到错误在你选择现场

+0

如何指定PLATFORMTYPE作为参数传递给platformVersion? –

+0

确定它说'groovy.lang.MissingPropertyException:没有这样的属性︰platformType类:Script1' –

+0

使用'活跃选择反应参数'并指定它'引用参数= platformType' – daggett

0

看起来你缺少的else部分if

它应该是:

if ('android' == platformType) { 
    return ['7.0', '6.0'] 
} else if ('ios' == platformType) { 
    return ['10.0', '9.0'] 
} else return [] 
+0

我刚刚检查,它没有工作 –

+0

它显示任何错误?你尝试过吗? – Rao

+0

我试过了。它不显示任何错误。请参阅我对@daggett的回应 –