Anybody has the script which can log the work automatically on the Jira ticket.
We are using Tempo Timesheets and for us this script in postfunction works just fine:
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import is.origo.jira.plugin.common.TempoWorklogManager
import com.tempoplugin.core.datetime.api.TempoDateTime
import com.tempoplugin.platform.api.user.TempoUser
@WithPlugin("is.origo.jira.tempo-plugin")
@PluginModule
TempoWorklogManager tempoWorklogManager
TempoUser tempoUser
Long timeToLog = 300L //5min in seconds
Long timeSpent = issue.getTimeSpent() ? (issue.getTimeSpent()+timeToLog) : timeToLog
Long remaining = issue.estimate ? (issue.estimate - timeToLog) : 0 // calc remaining estimate if set
issue.setTimeSpent(timeSpent)
tempoWorklogManager.create(
issue.id,
TempoDateTime.now(),
"Auto-created worklog",
null, //attributes
timeToLog,
0L,
remaining,
tempoUser,
[:]
)
Thank you both for your suggestions.
As we are using script runner plugin so I worked on the script and its working fine as expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
below is the code working fine if i provided the start date and end date manually ..
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
CustomField startDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(new Long(10250));
def startDateValue = issue.getCustomFieldValue(startDate)
log.error "Start Date : ${startDateValue}"
CustomField endDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(new Long(10251));
def endDateValue = issue.getCustomFieldValue(endDate)
log.error "End Date : ${endDateValue}"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd")
String startDateVal = sdf.format(startDateValue) //2018-04-21
String endDateVal = sdf.format(endDateValue)
log.error " After format : Start Date ${startDateVal} - End Date : ${endDateVal}"
def body = '''{
"worker": currentUser,
"comment": "auto work log.",
"started": startDateVal,//here if i add date manually then its working fine
"endDate": endDateVal, //here if i add date manually then its working fine
"timeSpentSeconds": 28800,
"originTaskId": "TEST-1",
"remainingEstimate": 0,
"includeNonWorkingDays": false,
"attributes": {}
}'''
what i am doing wrong here...anybody can help me out with this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it works fine when you add date manually, so I guess problem in types cast.
You need to find what type of data expected in "started" and "endDate" fields. I may be Date or something else but your variables is String.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @evzensx
It's my mistake, actually, I have fixed it but did not update here.
The issue is with worker..it accepts the user name/key in lower case. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Yogesh Mude
We have an app that does exactly this. EasyTime — An automatic time tracking app for Jira
It will log time as you work through your tickets, without having to start or stop a timer or changing the ticket status.
It works on the relative priority of events which you can configure. It is a new app, and we would love you to give it a try and give us feedback. You can always reach us at support@techtime.co.nz with any questions :)
Cheers
Poorvi
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.