I got this shared library vars/libOne
that takes composeFileNames
parameter as a list of strings.
#!/usr/bin/env groov
def call(String param1, String param2, String parm3, String[] composeFileNames ) {
String s =''
for (int i = 0; i < composeFileNames.size(); i++) { s +=' -f ./'+ composeFileNames[i] }
}
....
this libOne
is called in another shared library /vars/libTwo
were I defined pipeline steps and Map variables I pass in Jenkins:
#!/usr/bin/env groovy
def call(Map pipelineParams) {
node (...) {
stage("call libOne"){
libOne (pipelineParams.param1, pipelineParams.param2, pipelineParams.param3, pipelineParams.composeFileNames )
}
I want to call my libTwo in jenkins and pass two String parameters as composeFileNames
:
@Library('myLib ') _
libTwo(param1: 'string ',
param2: 'string',
param3: 'string',
composeFileNames: ['string1','string2']
)
The question is how do I do that correctly , because the above code gives me the error:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: dockerComposeVicDeploy.call() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.String, java.util.ArrayList) values: [param1, pamam2, param3, ...]
As a quick guess, you're passing in the default Groovy construct (an ArrayList), when you want to pass in a String array (String []). Luckily, that's easy... give this a try?
@Library('myLib ') _
libTwo(param1: 'string ',
param2: 'string',
param3: 'string',
composeFileNames: ['string1','string2'] as String []
How do I convert a Groovy String collection to a Java String Array?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.