Hi Jira Community,
I'am want to make an automation so that when an issue is transitioned to "Done" it will automatically set the custom field "actual end date" to current date (not due date or target end date, but the actual date it's moved to "Done").
My primary question:
- What is the correct JQL?
Supplemental questions:
- Maybe are other easier ways than JQL?
- Finally, should I start learning basic JIRA JQL? (I'am new in the job as a project coordinator in IT - no coding experience).
Here is my JQL, that didn't work:
{
"fields": {
"actual end date": {now.dayOfMonth}
}
Audit log regarding the automation that was tried to implement:
Hi!
Let's input worklog first, WorklogInput will help you
https://docs.atlassian.com/jira-rest-java-client-api/2.0.0-m31/jira-rest-java-client-api/apidocs/
like this
public boolean addWorklog(IssueEx issue, String comment) {
try {
URI worklogUri = getIssue(issue.id).getWorklogUri();
WorklogInputBuilder wlBuilder = new WorklogInputBuilder(worklogUri);
wlBuilder.setMinutesSpent(issue.timeSpent);
wlBuilder.setComment(comment);
jiraRestClient.getIssueClient().addWorklog( worklogUri, wlBuilder.build() );
return true;
} catch (Exception e) {
LOGGER.warning( "jira rest client update issue error. cause: " + e.getMessage() );
return false;
}
}
Hope it helps
Cheers,
Gonchik Tsymzhitov
Hi, Gonchik. Thanks for your comment.
I tried the code that you gave and I got an error as follows. What should I do?
Exception in thread "Thread-1" java.util.concurrent.RejectedExecutionException: Task com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable@3f10924d rejected from java.util.concurrent.ThreadPoolExecutor@39e30c40[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateExecutor.execute(SettableFuturePromiseHttpPromiseAsyncClient.java:171)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1.doCancelled(SettableFuturePromiseHttpPromiseAsyncClient.java:68)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalContextAwareFutureCallback$3.run(SettableFuturePromiseHttpPromiseAsyncClient.java:152)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:90)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalContextAwareFutureCallback.cancelled(SettableFuturePromiseHttpPromiseAsyncClient.java:147)
at org.apache.http.impl.client.cache.CachingHttpAsyncClient$2.cancelled(CachingHttpAsyncClient.java:636)
at org.apache.http.concurrent.BasicFuture.cancel(BasicFuture.java:135)
at org.apache.http.impl.nio.client.DefaultResultCallback.cancelled(DefaultResultCallback.java:57)
at org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.cancel(DefaultAsyncRequestDirector.java:533)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.doExecute(AbstractHttpAsyncClient.java:471)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.access$000(AbstractHttpAsyncClient.java:101)
at org.apache.http.impl.nio.client.AbstractHttpAsyncClient$1.run(AbstractHttpAsyncClient.java:485)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can add the worklog like you said Gonchik, thanks.
However, I cannot still resolve the issue. It says "Time Spent is required", again :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, have you checked in UI worklog has been added?
Also can you confirm, is it possible resolve issue from UI?
Looks like your validator in Jira does not work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeap, worklog(s) has added and I can resolve issue from UI.
"Time Spent" fields is required in "Required Close Screen". Because of that I got "Time Spent is required" error.
Also, in UI, if I don't enter any value in "Time Spent" field, I got the same error in UI, too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, after addWorkLog method have you seen any changes in UI?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, in issue's page, a work log added after addWorkLog method. For that, additionally I add a ".claim()" at the end of the
jiraRestClient.getIssueClient().addWorklog( worklogUri, wlBuilder.build() );
line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.