andrew.kazyrevich's Avatar


23 Dec, 2016 01:48 AM

We deploy a lot of packages, so when we create a new release it often becomes a pain to click "Last" on each package individually, in case we need to deploy last (not latest) versions of them.

So I created a Greasemonkey script which selects all "Last" or all "Latest" radio buttons once you click on the "Last" or "Latest" column header in the table.

However, this doesn't seem to work - perhaps something is not propagated in Angular. Can anyone take a look please? Hopefully I'm missing something small here!

// ==UserScript==
// @name Octomonkey
// @namespace
// @version 0.1
// @description Bulk click on the radio buttons in Release Editor
// @grant none
// @include*
// @require
// ==/UserScript==
(function() {
    'use strict';
    function whenLoaded(selector, callback) {
        var retry = function(repeats, callback) {
            if($(selector).length > 0) {

            var maxRepeats = 5;
            console.log('[Octomonkey] selector not found: ' + selector);
            if (repeats < maxRepeats) {
                setTimeout(function() { retry(repeats, callback); }, 500);

        $(document).ready(function() {
            retry(0, callback);
    // 1. Release editor:
    // when "Last" clicked select all last packages
    // when "Latest" clicked select all latest packages
    whenLoaded("release-editor", function() {
        $('abbr').on('click', function() {
            var versionType = $(this).text().toLowerCase();
            //uncheck all and check only the version type ones
            $(":radio[ng-model='pack.VersionType']").prop('checked', false);
            var items = $(":radio[value=" + versionType + "]");
            items.prop('checked', true);
            //update ng model
            for (var i = 0; i < items.length; i++) {
                var itemScope = angular.element(items[i]).scope();
                var newVersion = (versionType === "last") ? itemScope.pack.LastReleaseVersion : itemScope.pack.LatestReleaseVersion;
                itemScope.packageVersionChanged(itemScope.pack, newVersion);

  1. 1 Posted by andrew.kazyrevi... on 23 Dec, 2016 01:51 AM

    andrew.kazyrevich's Avatar

    Thanks for your email.

    I'm currently Out of Office with limited access to emails, and will be back on Monday, January 2.

    In my absence please contact Sergey Stoyan [email blocked]


  2. Support Staff 2 Posted by Henrik Andersso... on 04 Jan, 2017 11:00 PM

    Henrik Andersson's Avatar

    Hi Andrew,

    I've tested your script in Chrome (with the Tampermonkey extension) and it seems to work correctly for me without modification (I did see that there was a missing ; on line 26 but it worked without it anyway), when I click the Last header it selects all the packages in the Last column and if I click the Latest header it selects all the packages in the Latest column.

    Could you let me know what browser you are using?


  3. 3 Posted by andrew.kazyrevi... on 04 Jan, 2017 11:15 PM

    andrew.kazyrevich's Avatar

    Hi Henrik,

    Yeah the radio buttons do get selected - but the changes are not propagated to the release.

    Ie, by default "Latest" items are selected. Then I click on the "Last" column header and Greasemonkey selects "Last" items for all packages. But when I click "Create Release" I see that Octopus picked up "latest" packages to deploy, not the "last" ones.

    I think it's not enough to select radio buttons on the UI, the script needs to update Angular models - which is why I added "//update ng model" code. But looks like it's not enough.

    If some UI developer from Octopus team could advise that would be great!

  4. Support Staff 4 Posted by Henrik Andersso... on 04 Jan, 2017 11:48 PM

    Henrik Andersson's Avatar


    On line 44, you need to add .trigger('click') and that should resolve the issue for you (you should also be able to get rid of lines 46-51 after making that change).


  5. 5 Posted by andrew.kazyrevi... on 05 Jan, 2017 01:06 PM

    andrew.kazyrevich's Avatar

    Henrik - thanks, works like a blast now!

    One more thing, the script seems to break Dashboard with the following:

    TypeError: domElement.popover is not a function
        at HTMLSpanElement.<anonymous> (
        at Function.each (eval at <anonymous> (:2:297), <anonymous>:8:5257)
        at init.each (eval at <anonymous> (:2:297), <anonymous>:8:2013)
        at Object.bindPopovers (
        at fullRender (
        at Octopus.ReleaseMatrix.matrix.render (
        at Function._.each._.forEach (
        at renderDashboard (
        at fullRender (

    Is it something I could fix in the script to prevent the problem?

  6. Support Staff 6 Posted by Henrik Andersso... on 05 Jan, 2017 11:27 PM

    Henrik Andersson's Avatar


    If you update the @include URL to have /*/projects/*/releases/create instead of just *, the script will only run on the release creation screen.

    I've created this UserVoice ticket to provide first class support for your scenario and see what the community thinks about it, as we don't generally recommend writing these types of scripts as it may (as you've seen) interfere with other parts of the app.


  7. 7 Posted by andrew.kazyrevi... on 06 Jan, 2017 04:42 AM

    andrew.kazyrevich's Avatar

    Thanks for the uservoice ticket!

    Speaking of @include, it doesn't seem to work for me - possibly because Tampermonkey doesn't understand urls with hashes as per

    (ie. if I put `@include https://our.octopus/*/projects/*/releases/create` the script doesn't show up on the Create Release page at all)

  8. Support Staff 8 Posted by Henrik Andersso... on 06 Jan, 2017 04:50 AM

    Henrik Andersson's Avatar


    I tested this in Tampermonkey on Chrome before suggesting it to you and it worked fine for me so I'm not sure why it doesn't work for you sorry.

    Thank you,

  9. Paul Stovell closed this discussion on 06 Apr, 2017 03:11 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac