jira-plugin
jira-plugin copied to clipboard
Be able to use build/environment parameters in jql selector
Feature Request
Plugin Version => 3.7
When using Jira: Update relevant issues or Jira: Issue custom field updater, they are not able to read build parameters in JQL selector and in explicit selector.
What I am trying to do is, instead if writing key = "EXAMPLE-1", I want to be able to write key = ${IssueId} which IssueId is a parameter defined in the job.
- Since $ is preserved for Jira, I tried to use escape character as well (key = \${IssueId} or key = \\${IssueId})
- I thought maybe the issue is related with missing quotation marks so I tried key = "${IssueId}" or key = "\${IssueId}"
- I tried to add quotation marks in the build parameter (IssueId) instead of jql query (eg. if the issue id is TEST-123, then the parameter on the job is "TEST-123")
None of them worked. If I wrote a hardcoded issue id instead of a build parameter, it works flawlessly.
I noticed a similar feature is requested for IssueFieldUpdateStep to be able to use build/environment variables in field value when updating a custom field in JIRA with a given value. It has been implemented with the release of 3.2, and here is the commit message that contains the change.
I also checked the test code for JqlIssueSelector;
- It creates a jql selector with a jql containing hardcoded issue id,
- Selector sends the jql to session in findIssueIds() method,
- Session passes it to JiraRestService,
- JiraRestService searches issues by passing jql to JiraRestClient
So, it looks like we need to expand the sql to envVars before sending it to JiraRestClient through JiraRestService.
I also found out that same or similar feature is requested in Jenkins Jira page, here are those issues;
Hi @mrvcmrvc,
Very good analysis and as you pointed out, this was just not implemented fully in all the steps. Maybe that logic could be extracted and use across all the steps (some refactoring love ;) )
Would you have sime time to spend and contribute a Pull Request with a fix? Alternatively, please consider sponsoring one of the maintainers to spend some time on this :-)
Hey @rantoniuk
Thank you for the response. I agree, extracting the functionality and referencing it from all the required steps would be the cleanest solution.
Since I am kind of urgently in need of it, I will work on it and create a PR for the repository as soon as possible 👍