如何将Jenkins参数传递给Fabric?

时间:2015-08-13 15:57:32

标签: shell jenkins fabric

我有一个具有文本参数的Jenkins构建作业。该参数是一个URL,我需要将其传递给Fabric。如果网址包含" ="然后织物爆炸了。

示例参数值LOGOURL:http://example.com/test.jpg?foo=bar

我的执行shell命令:

fab -f create-demo.py main:sitename="$SITENAME",domainname=$DOMAINNAME,logourl="$LOGOURL",bgurl="$BGURL",host=test.example.com

詹金斯错误:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 700, in main
    commands_to_run = parse_arguments(arguments)
  File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 536, in parse_arguments
    k, v = result
ValueError: too many values to unpack
Build step 'Execute shell' marked build as failure

如何正确传递LOGOURL参数,以便Fabric不会死?

1 个答案:

答案 0 :(得分:1)

Fabric中的

Equals signs can be escaped with backslashes。因此,请尝试将LOGOURL设置为http://example.com/test.jpg?foo\=bar

如果您无法更改LOGOURL的值,那么您可以尝试使用shell为您转义=

fab -f create-demo.py main:sitename="$SITENAME",domainname=$DOMAINNAME,logourl=${LOGOURL/=/\\=},bgurl="$BGURL",host=test.example.com