Help running 'aws elbv2 modify-listener --default-actions' in Jenkins pipeline

54 views
Skip to first unread message

ZillaYT

unread,
Oct 17, 2018, 12:11:54 PM10/17/18
to Jenkins Users
I'm able to run this on my terminal (Macbook)

$ aws elbv2 modify-listener --listener-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/sb-zift-admin-lb/123456789012/abcdefghij12 --default-actions Type=redirect,RedirectConfig="{Protocol=HTTPS,Port=443,Host='#{host}',Query='#{query}',Path='/#{path}',StatusCode=HTTP_301}"

or

$ aws elbv2 modify
-listener --listener-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/sb-zift-admin-lb/123456789012/abcdefghij12 --default-actions '[{"Type": "redirect", "RedirectConfig": {"Protocol": "HTTPS", "Port": "443", "Host": "#{host}", "Query": "#{query}", "Path": "/#{path}", "StatusCode": "HTTP_301"}}]'

But when I script this into Jenkins pipeline, it doesn't work for me. Like this...

def httpListenerArn = arn:myAWSlistener
def defaultActions = '[{\\"Type\\":\\"redirect\\",\\"RedirectConfig\\":{\\"Protocol\\":\\"HTTPS\\",\\"Port\\":\\"443\\",\\"Host\\":\\"#{host}\\",\\"Query\\":\\"#{query}\\",\\"Path\\":\\"/#{path}\\",\\"StatusCode\\":\\"HTTP_301\\"}}]'
sh
= """
    aws elbv2 modify-listener --listener-arn $httpListenerArn --default-actions \\'$defaultActions\\'
"""



I get this output on the console

+ aws elbv2 modify-listener --listener-arn arm:mySWSListener --default-actions '[{"Type":"redirect","RedirectConfig":{"Protocol":"HTTPS","Port":"443","Host":"#{host}","Query":"#{query}","Path":"/#{path}","StatusCode":"HTTP_301"}}]'

Error parsing parameter '--default-actions': Expected: '=', received: ''' for input: '[{"Type":"redirect","RedirectConfig":{"Protocol":"HTTPS","Port":"443","Host":"#{host}","Query":"#{query}","Path":"/#{path}","StatusCode":"HTTP_301"}}]' ^

If I cut/paste what Jenkins spits out (command after + in output console) onto my terminal, it works. Any clues?

Thanks!


Reply all
Reply to author
Forward
0 new messages