Automatically chain several transitions in Jira workflow - jira

In a JIRA workflow, I would like to automatically execute several transitions one after the other when a certain condition is triggered. How can I do that ?
I have set up a Jira workflow that includes the following statuses
- ToDo (new issue)
- Ready (work planned)
- InProgress (ongoing work)
The normal course of action is to go from ToDo to Ready (is ready transition) and then from Ready to InProgress (start progress transition).
Whatever the current status (ToDo or Ready) of the issue, I would like to move it to InProgress when a branch is created in Bitbucket or a commit is created. That means that if the issue is in the ToDo status, creating a branch or adding a commit should automatically execute is ready and right after that start progress.
Note that I do not want to create any additional transition straight from ToDo to InProgress.
I have tried setting the branch created and commit created triggers on both is ready and start progress. But the best I achieve is to execute a single transition.

Note that I do not want to create any additional transition straight from ToDo to InProgress.
This is basically how Atlassian has designed the workflow and Issue transition logic, you're fighting against the system here.
I don't know if you also consider this as creating an additional transition but what you can do is link the already existing start progress transition to both Ready and ToDo statuses and add the branch hook to that one.
EDIT:
Well, I thought about this a bit more. What you can do is add a Webhook as a Post Function to the is ready transition. You would of course need to build an endpoint that accepts the Webhook and then, after checking that all the conditions pass, take that same Issue and transition it again to InProgress. This endpoint can either be a separate web-server or also a custom JIRA plugin, by the way.
This is what I could come up with limited to JIRA's default functionality. Depending on whether you're running a Server or Cloud instance there might be existing add-ons that provide you with this functionality but I cannot say for certain - you'd need to dig around at Atlassian Marketplace.
If, for example, you have the Script Runner add-on installed you could add a generic Post Function.. function to the issue which can execute any kind of code, you can replace the Webhook endpoint with that function.

Related

Atlassian Jira - What's called first on Jira state transition - Webhook or post function?

I'm very new to Jira, and still on exploring phase. I've an application that makes use of web hooks as well as post functions applied both on state change (transition).
Now as I understand, both gets called on State change, hence my question - Is there a priority if web hooks will be called first or post functions after state is changed ?
The execution of webhooks is a postfunction itself. At least indirectly.
Webhooks are based on certain issue events, like 'updated', 'created' etc. When looking at the default postfunctions of a transition, there is an entry at the end which fires an event for this transition. On a 'create' transition, this will be a 'issue created event' but on most others it will be a 'generic event'. If this event matches the webhook settings, it will be triggered at that point.
It is also possible to create custom events for more specific execution than what the built-in events allow for. You can also control the order of the postfunctions and fire the event before some other action you want executed afterwards.
This is documentation on such a custom event implementation. The same principle applies to the default events included in Jira:
https://confluence.atlassian.com/jirakb/how-to-use-a-webhook-with-a-custom-event-779160676.html

Show help about comment triggered jenkins jobs in gerrit

I have a gerrit - jenkins setup. Several jenkins jobs are started by a trigger based on a comment inserted to gerrit. The number of comment based triggers increases continuously. The project has a separate document with information what keyword in a comment executes what action.
It would be nice to provide a list of keywords directly in gerrit so developers do not need open documentation when searching for a specific keyword. Is there a way how to customize gerrit to show some hints when a user edits a comment?
Please follow the Checks plugin - currently is active development. It is/will be a complete redesign of how CI will do checks and how users interact with the CI checks being run. I don't think there's Jenkins integration for this already other than (custom) Groovy scripting polling the REST API at the time of writing.
The UI will allow users to trigger, re-run checks without the need for adding some magic comment! :-)
It's currently deployed on the Gerrit of Gerrit for purely optional checks:
So far (Gerrit 3.0.0) there isn't a way to do that.

Summary comment on github pull request from different Jenkins jobs

I have multiple jobs for one Pull requests running on Jenkins.
When a build is done, a comment is posted by a github account to inform it was done, so people get a notification.
It was fine when it was one job per pull request but now it is more spam than anything else.
One simple solution would be to have notifications on build check but it is not provided by github.
Another way would be to get a summary from those jobs when all are done, but I also don't have any idea on how to proceed on this.
Would there be a more cleaner way or a plugin doing this?
You can try using MultiJob plugin.
Create a parent Job and under that add all your jobs. And configure in such a way that, it triggers the parent job which in turn triggers the child job.
This way, it will notify the github only when all the child jobs are completed.

Is there a way to configure a view of builds that I started in Jenkins?

We have 'try' build jobs that developers can initiate with parameterized variables to point to a particular branch for pulling the code and trial running the build in jenkins. Is there a way I can customize a custom personal view showing only the builds that I have started?
The custom way
I think there's a way to customize a personal view by coding / modifying your Jenkins installation, jan-molak worked on that feature here.
You can check the commits and maybe implement something by your own, especially this and this.
The plugin
Take a look on View Job Filter If you configure it, there are options which seems to acomplish what you want:
Logged-in User Relevance Filter: This adds/removes jobs based on their
relevance to the logged in user. For example: matching jobs that were
started by the user, or where the user committed changes to the source
code of the job; matching jobs with a name that contains the user’s
name or login id.

How to trigger status update on a schedulle

I need to automatically update statuses of issues that satisfy certain conditions (e.g. some custom date field in the issue is less than 30 days to the current date) in Jira Service Desk.
It seems like there is no suitable trigger available in the Workflow automation.
Can someone pls advise how this could be implemented?
We are using latest version of Jira running in a Cloud.
Thanks
You can add your own postfunctions to workflow transitions (in Groovy if i'm not mistaken). For that go to your workflow, select the transition and add a custom postfunction.
A different way (that may be a bit more complicated) is to work with the Jira REST API. There is also a jira-python lib that is using that API.
So you could write a script that checks all your tickets using JQL and updates these tickets according to your condition.
Syntax could be like this
def checkIssue(issue):
if issue.fields.status.name == "Done":
// do something
issues = jira_connection.search_issues("updates <- 1d")
for i in issues:
checkIssue(i)
Keep in mind that you can't simply set the status in the issue object, you have to make transitions according to your workflow. Could be like this:
jira_connection.transition_issue(issue, '212')
where 212 is the ID of your workflow transition.

Resources