Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,600
Community Members
 
Community Events
177
Community Groups

How can I iterate over a String[] returned by split text field method?

Edited

Hi,

I'm trying to make multiple requests over automation to a Web Service (API) when a new release is released.

So, I'm defining some parameters over the release description (such as "Services: jst-core-service(v2.0.0);jst-xpto-service(v2.1.2);jst-whatever-service(v1.9.9)") and then I extract the release description and try to create a branch from a smart value variable.

I don't know why but it isn't working, could anyone help me?

 

Screen Shot 2022-12-06 at 13.55.22.pngScreen Shot 2022-12-06 at 13.55.31.pngScreen Shot 2022-12-06 at 13.55.45.pngScreen Shot 2022-12-06 at 13.55.56.pngScreen Shot 2022-12-06 at 13.56.13.png

Log:

Screen Shot 2022-12-06 at 13.56.55.png

 

As you can see, the Advanced Branching isn't working well.

1 answer

1 accepted

1 vote
Answer accepted
Darryl Lee Community Leader Dec 06, 2022

Hi @Felipe Bonezi --

So the trick is that Variables outside of Branches don't always work so well. I got your regexes to work by making one small change. I put the first one directly into the Advanced Branching block:

Screen Shot 2022-12-06 at 8.20.37 PM.png

Once I made that change I was able to create variables inside the branch just fine and echo them out to the audit log, so they should also work fine in your Web Request:

Screen Shot 2022-12-06 at 8.21.16 PM.png

Please let us know if this resolves the issue!

Darryl Lee Community Leader Dec 06, 2022

Oops, and because I wasn't careful in my typing, I forgot the "" after "Services", which is what resulted in that extra one before the first repository.

@Darryl Lee it worked in a way.

The Smart Values are creating right but the request isn't working.

It returns 404 Not Found, so I believe that {{repository}} used as request path isn't working.

 

Screen Shot 2022-12-07 at 12.36.58.png

The other problem is when you use the same version value.

Try to use every service with `v2.0.0`.

@Darryl Lee I fixed using smart value as the full url.

But right now the body custom data isn't working... It returns 500 Internal Server Error and it's related to an invalid JSON body.

If I use into Postman, works.

 

Screen Shot 2022-12-07 at 13.26.16.pngScreen Shot 2022-12-07 at 13.27.20.png

Darryl Lee Community Leader Dec 07, 2022

Again, I would advise against using "Create variable" to create your {{githubBody}} an {{githubUrl}} because as mentioned before, variables are a little... unreliable, having to do with what order Automation runs stuff in, etc etc.

Instead, I would do what you did before, putting the URL directly into the Web Request to github with the {{respository.urlEncode()}} variable added, and similarly, the put the {{versionName.urlEncode()}} directly in the Custom data of the Web Request.

I know variables are the "right way" or "cleaner way" to do things. But they don't reliably work in Automation, so sometimes it's best to put the smart values directly into the actions.

Darryl Lee Community Leader Dec 07, 2022

Oh, I did have one thought - can you post a screenshot of what was actually in {{githubBody}}? Did you include the braces and everything so that it generated something like:

{"tag_name":"v1.0.0", "target_commitish":"master", "name":"v1.0.0", "body":"Description of the release", "draft":false, "prerelease":false, "generate_release_notes":true}

It's always helpful to output to the Audit Log what the content of that variable might look like.

@Darryl Lee 

I've tried in every way but it doesn't work.

Screen Shot 2022-12-07 at 18.41.33.pngScreen Shot 2022-12-07 at 18.41.26.png

Darryl Lee Community Leader Dec 07, 2022

And you also tried *without* using an intermediary variable?

Yes, if I don’t use {{githubUrl}} it doesn’t work. Even if I use the full endpoint as string, it doesn’t work. 

is there any way to log the hole request?

if I copy and paste the same content into Postman, works.

 

Screen Shot 2022-12-07 at 19.53.00.png

@Darryl Lee it worked doing everything inside the Send Web Request.

It's very painful to work creating variables as you said.

 

Screen Shot 2022-12-07 at 20.12.28.png

Like Darryl Lee likes this
Darryl Lee Community Leader Dec 07, 2022

Glad it worked. Yeah, it's a bummers variables don't work more reliably.

Note there's a minor typo in your headers. Should be Content-Type, I think.

Like Felipe Bonezi likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS

Atlassian Community Events