如何将任意数量的参数传递给Jenkins共享库

时间:2019-02-20 04:40:01

标签: jenkins groovy jenkins-groovy jenkins-shared-libraries

我得到了这个共享库vars/libOne,它使用composeFileNames参数作为字符串列表。

#!/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] }
               } 
....

如果我定义了在Jenkins中传递的管道步骤和Map变量,则在另一个共享库libOne中调用了此/vars/libTwo

#!/usr/bin/env groovy
def call(Map pipelineParams) {
    node (...) {
      stage("call libOne"){
                libOne (pipelineParams.param1, pipelineParams.param2, pipelineParams.param3, pipelineParams.composeFileNames  )
}

我想用jenkins调用我的libTwo,并以composeFileNames的形式传递两个String参数:

@Library('myLib ') _
        libTwo(param1: 'string ',
               param2: 'string',
               param3: 'string',
               composeFileNames: ['string1','string2']

问题是如何正确执行此操作,因为上面的代码给了我错误:

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, ...]

1 个答案:

答案 0 :(得分:0)

作为一个快速的猜测,当您要传递String数组(String [])时,您将传递默认的Groovy构造(ArrayList)。幸运的是,这很容易...试试看吗?

2019-02-20 04:27:30.580666: E tensorflow/stream_executor/cuda/cuda_driver.cc:806] failed to allocate 836.47M (877106944 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY: out of memory
2019-02-20 04:27:30.612909: E tensorflow/stream_executor/cuda/cuda_blas.cc:464] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2019-02-20 04:27:30.619060: E tensorflow/stream_executor/cuda/cuda_blas.cc:464] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2019-02-20 04:27:30.625466: E tensorflow/stream_executor/cuda/cuda_blas.cc:464] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2019-02-20 04:27:30.630800: E tensorflow/stream_executor/cuda/cuda_blas.cc:464] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2019-02-20 04:27:30.636172: E tensorflow/stream_executor/cuda/cuda_blas.cc:464] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2019-02-20 04:27:30.641168: E tensorflow/stream_executor/cuda/cuda_blas.cc:464] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
2019-02-20 04:27:30.723663: E tensorflow/stream_executor/cuda/cuda_dnn.cc:373] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
2019-02-20 04:27:30.726611: E tensorflow/stream_executor/cuda/cuda_dnn.cc:373] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
Traceback (most recent call last):
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
    return fn(*args)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
     [[{{node conv1/Conv2D}} = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:worker/replica:0/task:1/device:GPU:0"](adam_optimizer/gradients/conv1/Conv2D_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv1/Variable/read_S15)]]
     [[{{node Mean_G10}} = _Recv[client_terminated=false, recv_device="/job:worker/replica:0/task:1/device:CPU:0", send_device="/job:worker/replica:0/task:1/device:GPU:0", send_device_incarnation=-8510199717243775654, tensor_name="edge_245_Mean", tensor_type=DT_FLOAT, _device="/job:worker/replica:0/task:1/device:CPU:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mnist_distributed.py", line 234, in <module>
    tf.app.run()
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "mnist_distributed.py", line 222, in main
    feed_dict={features: batch[0], labels: batch[1], keep_prob: 1.0})
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/training/monitored_session.py", line 671, in run
    run_metadata=run_metadata)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/training/monitored_session.py", line 1156, in run
    run_metadata=run_metadata)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/training/monitored_session.py", line 1255, in run
    raise six.reraise(*original_exc_info)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/six.py", line 693, in reraise
    raise value
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/training/monitored_session.py", line 1240, in run
    return self._sess.run(*args, **kwargs)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/training/monitored_session.py", line 1312, in run
    run_metadata=run_metadata)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/training/monitored_session.py", line 1076, in run
    return self._sess.run(*args, **kwargs)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 929, in run
    run_metadata_ptr)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1152, in _run
    feed_dict_tensor, options, run_metadata)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
    run_metadata)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
     [[node conv1/Conv2D (defined at mnist_distributed.py:118)  = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:worker/replica:0/task:1/device:GPU:0"](adam_optimizer/gradients/conv1/Conv2D_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv1/Variable/read_S15)]]
     [[{{node Mean_G10}} = _Recv[client_terminated=false, recv_device="/job:worker/replica:0/task:1/device:CPU:0", send_device="/job:worker/replica:0/task:1/device:GPU:0", send_device_incarnation=-8510199717243775654, tensor_name="edge_245_Mean", tensor_type=DT_FLOAT, _device="/job:worker/replica:0/task:1/device:CPU:0"]()]]

Caused by op 'conv1/Conv2D', defined at:
  File "mnist_distributed.py", line 234, in <module>
    tf.app.run()
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "mnist_distributed.py", line 195, in main
    features, labels, keep_prob, global_step, train_step, accuracy, merged = create_model()
  File "mnist_distributed.py", line 148, in create_model
    y_conv, keep_prob = deepnn(x)
  File "mnist_distributed.py", line 76, in deepnn
    h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
  File "mnist_distributed.py", line 118, in conv2d
    return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 957, in conv2d
    data_format=data_format, dilations=dilations, name=name)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
    op_def=op_def)
  File "/hadoop/yarn/nm-local-dir/usercache/root/appcache/application_1550484758208_0014/container_1550484758208_0014_01_000004/venv/tf/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1770, in __init__
    self._traceback = tf_stack.extract_stack()

UnknownError (see above for traceback): Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
     [[node conv1/Conv2D (defined at mnist_distributed.py:118)  = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:worker/replica:0/task:1/device:GPU:0"](adam_optimizer/gradients/conv1/Conv2D_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv1/Variable/read_S15)]]
     [[{{node Mean_G10}} = _Recv[client_terminated=false, recv_device="/job:worker/replica:0/task:1/device:CPU:0", send_device="/job:worker/replica:0/task:1/device:GPU:0", send_device_incarnation=-8510199717243775654, tensor_name="edge_245_Mean", tensor_type=DT_FLOAT, _device="/job:worker/replica:0/task:1/device:CPU:0"]()]]

How do I convert a Groovy String collection to a Java String Array?