Youtrack workflow via Github PullRequest

Hello,

We want to create a new workflow that moves a issue in the agile-board when a pull request is started in GitHub.
It should then be changed to "To Verify".
The following workflow unfortunately does not work. but why?

Thanks and best regards

3 comments
Comment actions Permalink
Official comment

Hello David,

thank you for your question.

First of all, you need to refer to `ctx.issue.pullRequests` since it's the correct name of the issue attribute (reference can be found here)

The `pullRequests` attribute is a set in the workflow API, so to work with it, you need to use, for example, `ctx.issue.pullRequests.added` (if you need to check the new PRs) and then take the first of these elements. Or, as an option, you can iterate over these `ctx.issue.pullRequests.added` with a forEach method.

As for the PR state, here you can check the PR states available with the workflow API: https://www.jetbrains.com/help/youtrack/incloud/v1-PullRequestState.html#properties

 

I hope this helps, please feel free to ask if you have any further questions and share your code, we'll be happy to help further.

Comment actions Permalink

Hello Liubov,

Thank you for your help. I understood better now, but unfortunately it doesn't work yet.

unfortunately, both examples do not work.

First example

return ctx.issue.pullRequests.added.first().state.name == ctx.PullRequestState.OPEN;

Second example

return ctx.issue.pullRequests.added.first().state.isNew;

 

Where is my mistake and is there a way to debug the code?

Thanks and best regards

 

0
Comment actions Permalink

Hello David, sorry for the delayed reply.

According to the docs, the syntax would be:

First example:

return ctx.issue.pullRequests.added.first().state.OPEN;

Second example:

return ctx.issue.pullRequests.added.first().state.isNew;

 

As for debugging, please use the workflow editor console along with the `console.log()` method in your code.

 

Feel free to ask if you have any further questions, we'll be happy to help.

0

Please sign in to leave a comment.