Priority Sorter Plugin

Skip to end of metadata
Go to start of metadata

This plugin allows Jobs to be prioritised based Queue Strategies and Priority Strategies.

Plugin Information

Plugin ID PrioritySorter Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
2.6
Jan 11, 2014
1.520
Source Code
Issue Tracking
Maintainer(s)
GitHub
Open Issues
Magnus Sandberg (id: emsa23)
Usage Installations 2013-Apr 1403
2013-May 1445
2013-Jun 1467
2013-Jul 1573
2013-Aug 1582
2013-Sep 1662
2013-Oct 1749
2013-Nov 1810
2013-Dec 1747
2014-Jan 1830
2014-Feb 1892
2014-Mar 1961

Description

This plugin adds the ability to assign different priorities to Jobs, the lower priority the job has the sooner the Job will run.

This can be very helpful when one wants to add low priority jobs but wants to have higher-priority jobs run first when hardware is limited or when there are different groups of Jobs that should share resources (equally).

Queue Strategies

There are four included Queue Strategies, the different Queue Strategies will sort the Queue differently.

Absolute

Each Job will be assigned a Priority, the lower the Priority the sooner the Job will be run.

Fair Queuing

Each Job will be assigned a Priority, the Queue will try to share the resources equally over the different priorities in a round-robin fashion.

Weighted Fair Queuing

The same as Fair Queuing but Jobs with lower Priority will be run more frequently than Jobs with higher Priority.

Assigning Priorities

Priorities can either be assigned directly on Jobs or, preferably, by assigning them by View.

Priority Strategies

It is possible to assign the Priority based on different Priority Strategies

  • Default Priority
  • Jobs Started By User
  • Jobs Started By CLI
  • Jobs started by Upstream Job
  • By using Job Parameter
  • Using the Jobs Health

Legacy Mode

The plugin can still operate in Legacy Mode and will then behave as the pre 2.0 version. It is however advised to either upgrade to the Advanced Mode or downgrade the plugin. 

The Legacy Mode will be removed in next major release.

Main Configuration

The main configuration of the plugin is done on the main Configurations Page and the Priority Strategy configurations done on its own page accessible from the root actions menu.

If you are already using the Priority Sorter and you're upgrading to the 2.0 you'll need to actively select to upgrade the configuration.

Go to the Jenkins main configuration page ad go to the Priority Sorter and you will see this:



to upgrade your system to advanced mode check the check-box and you will be able to configure the Advanced Mode.


You can now configure the plugin, after you are happy with the configuration use Save do not use Apply as this change will update internal data and switch to Advanced Mode.

 Please note that in when you switch to Advanced mode the switch will go through and update all your Jobs. This may take quite some time depending on how many Jobs you have.

The upgrade will convert your legacy priorities to Advanced  with the selected range.

If you are installing the Priority Sorter on a new system the configuration panel will directly show the Advanced Mode


In Advanced Mode it is preferred to use Views and Patterns to assign priorities rather than directly on Jobs using Priority allowing priorities on Jobs are therefore optional.

 Please note that if you are upgrading from Legacy Mode and want to keep the old priorities you must allow priorities on Jobs.

 Please note that in Advanced Mode generally lower number means higher priority, also see details on screen for the specifics on each Strategy. 

Assigning Priorities

When in advanced mode you will find the link to the page where you can assign priorities to each Job

On this page you will be able to assign priorities to Jobs by View and/or Pattern.
You will be able to create more than one rule and Jobs that matches more than one rule will be assigned priority by first match.
You can also  assign priorities based on extra strategies such as if the Job is launched by a User, rather than by cron, that Job can get another priority.
As above, rules are read from top and down and first match is used.

You can limit access to this functionality to Administrators only be checking the appropriate check-box on the main configuration page.

Run Exclusive

If a Job from a Run Exclusive JobGroup gets started Jobs from other JobGroups will stay blocked and will not get started until all Jobs from the Run Exclusive JobGroup in the Queue is finished, regardless of priority. 

Using the View Column

Since a Job can get a different Priority each time it is started the View Column cannot show the "correct" priority for the Job.

The column will show the priority used the last time the Job was launched, if the Job has not been started at all yet the column will show Pending.

Troubleshooting

To get some inside information on how and why a certain Job gets a certain Priority you can turn on some extra logging.

Logger to log is PrioritySorter.Queue.Items

To get more info on the assigned priorities and state transition of the items in the queue log on level FINE.

To get even more info on how the Jobs are matched to Job Groups and Rules to get the priority log on level FINER.

To get logging on when the QueueSorter is active log PrioritySorter.Queue.Sorter on level FINE.

Changelog

Version 2.6 (2014-01-11)

Fixes : issue #21310 CCE when a Queue.Task was not a Job
Fixes : issue #21316 PrioritySorter wrongly assumes Queue.Task is Job
Relates: issue #21314 Stack trace displayed on web page when attempting to configure PrioritySorter plugin

Version 2.5 (2014-01-08)

Fixes: issue #21289 Item Logging causing NPE
Fixes: issue #21284 Add some logging to show what the sorter is doing
Fixes: issue #21204 Add ability to boost recently failed Jobs

Version 2.4 (2014-01-02)

Fixes: issue #21173 Anonymous Users Can Configure Priorities
Fixes: issue #21119 Extend loggning to show assigned priority
Fixes: issue #21103 "Priorities are assigned top down by first match" does not work correctly (Thanks to Adam Gabryś for debugging help)

Version 2.3 (2013-12-20)

  • introduces the Run Exclusive Mode to deal with issue #11997
  • adds a new Priority Strategy to give Jobs the same priority as a UpstreamJob
  • some performance enhancements
  • hopefully fixes the deadlock issue in issue #21034
  • fixes the priority assignment issue on main configuration page

Fixes: issue #11997 Consider jobs in the Executors for priority sorter
Fixes: issue #21034 Jenkins Startup Deadlock - QueueSorter.installDefaultQueueSorter and Queue.init
Fixes: issue #20995 Default Priority always shows 1-5

Version 2.2 (2013-12-05)

Fixing bug that made the plugin switch to Advanced mode even though Legacy (1.3) data was present in the system. (Thanks to help from Matthew Webber)

Fixes: [JENKINS-8597] Deal with matrix builds better

Version 2.1 (2013-12-04)

Fixes bug that mapped all Jobs to all Views/JobGroups.

Version 2.0 (2013-12-02)

Introducing advanced queueing features with possibility to selected different strategies for how priorities are assigned and how the queue is sorted.

Thanks Oleg for testing, reviewing and helping out.

Version 1.3

Removed view column from default view (Thanks to work from larrys)

Version 1.2

Added View column to easily compare priorities between jobs (Thanks to work from cjo9900)

Version 1.1

Fixed a potential NPE when using the plugin on existing jobs without setting a default priority.

Version 1.0

Initial Release

Labels

Edit
plugin-misc plugin-misc Delete
plugin-listview-column plugin-listview-column Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Add Comment