Convert issue search URL into the search request

Issue #281 resolved
Andrey Kiyanovsky created an issue

Hi Fidel,

I'm looking for the opportunity to convert JIRA search request URLs, like:

https://track.namecheap.net/issues/?jql=project%20in%20(ATL)

into

project in (ATL)

to use the string in JQL post-functions.

Is it possible?

Thank you in advance, AK.

Official response

Comments (10)

  1. Fidel Castro Armario repo owner

    Hi Andrey,

    You can do it using post-function "Copy a parsed text to a field" with the following configuration:

    Captura de pantalla 2016-03-31 a las 20.26.54.png

    Text to be parsed is:

    "project in (" + replaceFirst(%{11300}, "^.*\\(", "")
    

    In the example the URL is originally in My URL custom field (field code %{11300}), and is transformed into an equivalent JQL query after post-function execution.

  2. Andrey Kiyanovsky reporter

    It doesn't work. Example:

    Field "Tasks" (multiline) has value: https://track.namecheap.net/issues/?jql=issuekey%20%3D%20API-21

    After mentioned post-function it is: project in (https://track.namecheap.net/issues/?jql=issuekey%20%3D%20API-21

    I'd like to have the following result: https://track.namecheap.net/issues/?jql=issuekey = API-21

    where all EncodeURL symbols replaced with original symbols. My final goal is to have a string "issuekey = API-21" to use it in JQL post-functions.

  3. Andrey Kiyanovsky reporter

    So my algorithm is the following: - convert %XX symbols to original symbols - cut leading "https://track.namecheap.net/issues/?jql=" - get the resulting "issuekey = API-21"

  4. Andrey Kiyanovsky reporter

    Fidel,

    sorry for misleading. I'd like to have universal decode, disregard of search URL. So Search URL might be any.

  5. Fidel Castro Armario repo owner

    Hi Andrey,

    Try using this text to be parsed:

    replaceAll(replaceAll(replaceAll(replaceFirst(%{11300}, "^.*jql=", ""), "%20", " "), "%3D", "="), "%22", "\"")
    

    That text supports encoding the following characters: %20 (space), %3D (=) and %22 (").

    You can add other characters following the obvious pattern of the expression. I will add a new function to the parser in next version of the plugin, so that we can write an expression that supports any encoded character.

  6. Andrey Kiyanovsky reporter

    Hi Fidel,

    yes, this straightforward method will work, but I'm not aware of all converted characters, so it's error-prone. This time I got away with ScriptRunner custom scripted post-function, but I'd really appreciate if you implement decoding.

    Thanks a lot, AK.

  7. Fidel Castro Armario repo owner

    Hi Andrey,

    You can format any URL using "Copy a parsed text to a field" post-function in advanced parsing mode with the following text expression:

    findModify(%{nnnnn}, "%[A-Fa-f0-9]{2}", getAscii(toInteger(substring(^%, 1, 3), 16)))
    

    replacing nnnnn with the field code of the field where the URL is stored.

    To use this solution you have to install version 2.2.12_beta_7.

  8. Log in to comment