Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

shell - Jenkins remotely triggered build- how to pass extended-choice-parameter

I'm trying to pass parameters while triggering Jenkins from a shell script. I succeeded in passing only string params and unfortunately I didn't find any way how to pass extended-choice-parameter. I searched a lot of time, but the few solutions which I found didn't serve my needs.

 curl -X POST -u $user_name:$api_token_string http://{my jenkins server}/job/{my job}/$branch/buildWithParameters?token=$api_token_name  
--data myParam=$myValue --data myOptions=option1 --data myOptions=option2

This code works well. It triggers the right job and passes the params. When "myParam" is a string parameter in the Jenkins pipeline and "myOptions" is an extended-choice-parameter in Jenkins pipeline.

The problem is that I can't use this code because "option1" and "option2" are arguments of my shell script and I can't know from advanced how many options the user will send (maybe 5 args).

I've tried to pass "options" as an array in several ways:

--data myOptions=options
--data myOptions=${options[*]}
--data myOptions=${options[@]}

but the pipeline knew only the first value of the array :(

so- any idea how to pass extended-choice-parameter (when there are multiple choices) or maybe in other words- how to pass an array to Jenkins pipeline from a shell script?

question from:https://stackoverflow.com/questions/65871906/jenkins-remotely-triggered-build-how-to-pass-extended-choice-parameter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...