Further I tried to create a sample app via ‘forge create’ and just added a console log message - still nothing is happening when the transition is done.
Code from the sample app created by template:
modules:
jira:workflowValidator:
- key: validator-test-example-workflow-validator
function: main
name: validator-test
description: A Jira workflow validator example.
function:
- key: main
handler: index.run
app:
id: ari:cloud:ecosystem::app/3d57354f-970e-4203-9228-481dab833560
export const run = ({ issue, transition: { from, to } }) => {
console.log('validator test:');
return {
result: false,
errorMessage: `Issue ${issue.key} is not ready for transition from status ${from.id} to ${to.id}`,
}
};
for good measurement I also tried to add the permission scopes for jira work:
Hi @mbrach,
Welcome to Developer Atlassian Community.
I have run the exact code as you pasted and everything works for me.
Have you added your validator to a workflow transition and published the workflow draft?
Additionally, I’d like to say that I don’t get the second part of your post (“for good measurement, I also tried to add the permission scopes for jira work”) as the code seems to be exactly the same.
But I do not see an error message or even a log message in the tunnel - do you?
It still is only deployed in development - but i think this should work as well? Or is this perhaps an limitation for validators?
Any other things I’ve could have missed?
2nd part:
Missed the correct copy & paste sorry… I will edit
@BeataSzturemska : I’ve added some screenshots, perhaps this helps you to point out what I am doing wrong… And Thank you in advance for the help
Hi @mbrach , what is this issue is assigned validator? This looks like it’s registered by a different app you created. I don’t know what that validator does but if I were to believe the description, it fails because the issue from the screenshot is unassigned. Therefore the transition fails on that validator and the validator-test is not triggered.
Can you keep validator-test as the only validator in the transition and check again if it in fact is not triggered?
The expected behavior IS to show an error, which is NOT happening…
FYI:
the Validator test is expected to not validate anything!
The expectation is: when a transition is happening, log an message to console and show an error anytime…
As you requested, I’ve removed the “issue is assigned” validator and kept the “validator-test”.
Result: still no console message, still no error shown in UI.
I also tried to deploy and install the validators in the production environment, this was also not changing anything…
So either the validator implementation is not working at all, or there are some limitations, prerequisitions or settings which are not done. My site was freshly created and besides installing some apps from the tutorials I did not change anything there.
We had a call with @mbrach and it turned out that the workflow, where the validator was used, was never assigned to the project where the issues have been created. It was because the project was of a team-managed type. When we created a company-managed project, the validators registered by the Forge app worked as expected.
As of now, there’s no way to use Forge transition rules in the team-managed project’s workflow.
Great work and wonderful support! Thank you very much!
Function based validator is now also working like expected
I gave feedback at the tutorial, that this limitation was not pointed out.
Only leaves the question why an workflow of an trashed project is still visible as active… In scheme view its shown
But that doesn’t bother me at all now