Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

sendng custom variables in automation webhook

Peet March 17, 2022
Hi Everyone, we are using an JIRA datacenter v8.20, and I`m trying to set up an automation rule, where an issue status change would trigger a webhook to be sent to gitlab to trigger a pipeline. Gitlab is listening for a webhook URL in the following format: https://gitlab.ch.glencore.net/api/v4/projects/2318/ref/REF_NAME/trigger/pipeline?token=TOKEN&variables[RUN_NIGHTLY_BUILD]=true
 
where I`m trying to pass variables like {{issue.[Custom Field 2]}} and things like that but JIRA won`t allow the curly brackets saying "Invalid URL provided" . I`ve read a lot of documentation and I tried the webhooks feature described at https://confluence.atlassian.com/adminjiraserver073/managing-webhooks-867028229.html as well but I think it only supports a limited amount of fields anyway.
Please let me know what do you suggest.

2 answers

1 accepted

0 votes
Answer accepted
Peet March 21, 2022

Meanwhile I got back an answer for this from support: 

 

Synopsis

it can be a little tricky to get the final value but I believe it's achivable.Not only Jira but most of the systems will fail if you pass a bracket in the URL it should be UTF-8 encoded for example

Plain text

Url encoded

[

%5B

Since you do know the endpoint you are reaching and the URL format is static for you , you can prepare the placeholder in advance and work on the variables one by one.

The webhook field states the required modification

Request parameters must be url encoded, smart values should use:  {{ value.urlEncode }} .

Which translates in your case for the example of variables[RUN_NIGHTLY_BUILD]=trueRUN_NIGHTLY_BUILD]*=*true which is a key value parameter string for both the key and the value to be URL encoded , if we try to encode the key :

Plain text

Url encoded

variables[

variables%5B

RUN_NIGHTLY_BUILD

  {{ issue.summary.urlEncode }} 

]

%5D

After encoding the key the URL would finally look like

 https://gitlab.ch......net/api/v4/projects/2318/ref/REF_NAME/trigger/pipeline?token=TOKEN&variables%5B {{ issue.summary.urlEncode }} %5D=true

considering that we didn't encode the value since it doesn't contain any special characters

Resolution & Next Steps

  1. Make sure to encode the URL parameter key and value , you can use a website encode to get the static values
  2. For the dynamic values that come from Jira you need to make sure you have the right value and encode it using urlEncode function
  3. You can test the variable output by using a test rule that comments the encoded smart value to make sure you have the correct output

You can create a webhook intercepted like PipeDream to see what is Jira sending and if it is correct for instance this rule delivers the summary as a request parameter in encoded value and the result is visible

0 votes
Stefan Salzl
Community Champion
March 17, 2022

Hi @Peet 

Without knowing your complete automation rule/webhook:

did you try to write the smart value without [] ? --> {{issue.Custom Field 2}} ?

 

If this doesn´t work please add screenshots of your settings. That would help to analyze your current situation.

Best
Stefan

Peet March 21, 2022

Please read the questions a bit more carefully next time, I mentioned that the curly brackets are the actual problem (you can read the official response from atlassian as well for the exact same question)

Appreciate your intention to help tho

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events