jira cli copy field value with spaces in custom field name

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2016

Hi all,

I inherited a situation where JIRA was not set up correctly, and am try to fix it.  One problem was custom fields were created for versioning.   So I am trying to go project by project and for all issues copy "Release Version" to "fixVersions".

After a short investigation, I determined that the cli was the best tool to use.  I am running this command:

./jira.sh --action runFromIssueList --search "project in (DGAGENTMAC)" --common "-a copyFieldValue --issue @issue@ --toIssue @issue@ --field ""Release Version"" --field2 fixVersions --asVersion"

and getting this:

Error: Unexpected argument: Version

I also tried these:

./jira.sh --action runFromIssueList --search "project in (DGAGENTMAC)" --common "-a copyFieldValue --issue @issue@ --toIssue @issue@ --field 'Release Version' --field2 'fixVersions' --asVersion"

Error: Unexpected argument: Version'

and 

./jira.sh --action runFromIssueList --search "project in (DGAGENTMAC)" --common "-a copyFieldValue --issue @issue@ --toIssue @issue@ --field 'customfield_10102' --field2 'fixVersions' --asVersion"

Remote error: Custom field ''customfield_10102'' is not valid.

How do I specify a field with a space in the name with the runFromIssueList cli action?

Thanks!

Robert

3 answers

1 accepted

1 vote
Answer accepted
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2016

You are on linux or mac, so use the other form of escaping quoting. Something like:

./jira.sh --action runFromIssueList --search "project in (DGAGENTMAC)" --common "-a copyFieldValue --issue @issue@ --field \"Release Version\" --field2 fixVersions --asVersion

If you are on JIRA 7.x, you don't need the --asVersion.

BTW, what version of JIRA are you using? And CLI version?

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2016

Thank you for the response.

I have only been using UNIX/Linux for 30+ years, you would think I would have known/tried that lol.  That did work for the spaces.  However if I need to copy from a custom field to a JIRA standard field it does not work.    I get this error with the exact command above:

Custom field 'fixVersions' is not valid.

If fixVersions is used for field it works great.  If I use it for field2 it fails.

I need to copy from the custom field to the standard field.

Thanks,

Robert

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2016

What version of JIRA and CLI? I know it works here on JIRA 7 and CLI 5.x. It will not work on JIRA release < 6.4.

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2016

Bummer.  We are upgrading to 7 later summer.    We are on 6.4.7 and cli 4.4.0    Maybe I will try to upgrade the cli.   Thanks!

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2016

After upgrading the plugin to 5.4, it worked!  Thank you!  That is why I love seeing Bob Swift on any add-on I purchase.  Between you and Atlassian,  The best support i ever experienced!!!!

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2016

Good. CLI 5.x added REST support for JIRA 6.4 which included expanded copyFieldValue support.

0 votes
Thu Trần Aroma July 17, 2017

anyone encounter the error with server and password?

Error: Parameter 'server' is required.
Error: Parameter 'password' is required.

 

I try the solution as suggested here but it can't help

https://community.atlassian.com/t5/Answers-Developer-Questions/JIRA-CLI-error-using-command/qaq-p/512912

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2017

Yes, what I did is to edit the jira.sh and put the server and password parameters in there as not to share those.  

--server https://myjiraserver.mydomain.com:8090 --user MyUser --password 'MyPassword' 

The server is the URL for your Jira site.  And then a user and password that you wish to log into with.  I have changed mine above as they are confiendtial info....

Thu Trần Aroma July 17, 2017

Thanks for your reply.

Could you please clarify the part 'edit the jira.sh'?

I've tried adding the server, user and password but never touch that jira.sh 

Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2017

Ignore the "edit the jira.sh"  That is a personal preference just add the arguments on the command line.

0 votes
Robert G. Nadon
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2016

Also one more little problem.   I tried to rename the field have - instead of space and that failed with:

./jira.sh --action runFromIssueList --search "project in (DGSERVER) and createdDate <= 2014-01-01" --common "-a copyFieldValue --issue @issue@ --toIssue @issue@ --field ""Found-in-Release"" --field2 ""affectsVersions"" --asVersion"

Run: -a copyFieldValue --issue DGSERVER-4663 --toIssue DGSERVER-4663 --field Found-in-Release --field2 affectsVersions --asVersion

Remote error: Custom field 'affectsVersions' is not valid.

It did work the other way but --field2 appears to need a custom field and I need it to be a JIRA field either fixVersions or affectsVersions.  The other way does not work as all it did was wipe out "Found in Release".  (Was on the sandbox so nothing serious just need a way to copy fields)

Suggest an answer

Log in or Sign up to answer