Skip to end of metadata
Go to start of metadata

Plugin Information

View Startup Trigger on the plugin site for more information.

The Startup Trigger plugin allows you to trigger a build when Jenkins nodes (master/slave) start.See GitHub for more usage info: https://github.com/jenkinsci/startup-trigger-plugin

Version History

Version 2.9.3 (April 13, 2018)

  • Fix JENKINS-50681 - Startup Trigger label list doesn't work with master
  • Fix JENKINS-45444 - Node parameter can no longer be a NodeParameter, it must be a LabelParameter
  • Minor code cleanup/updates

Version 2.8 (2017-01-12)

Version 2.7 (2016-10-10)

  • Fix JENKINS-38582 - Added "Run when temporarily online" support (Advanced option)

Version 2.6.3 (2016-09-16)

  • Fix JENKINS-22422 - Added node to build cause
  • Fix JENKINS-32659 - Added support for Cloudbees folders
  • Enabled use of label expressions in the trigger label field
  • Triggering node's name can be passed to jobs as a NodeLabel Parameter
  • No longer running disabled jobs
  • One single job can now be triggered by a list of labels

2.6-2.6.2 are omitted because they only contain updates to Maven configuration...

Version 2.5 (2015-12-02)

Version 2.4 (2013-04-28)

  • Enable to specify a string for the trigger label as a substring of the node label.

Version 2.3 (2013-02-13)

Version 2.2 (2013-02-07)

  • Fix label and log message

Version 2.1 (2013-01-26)

  • Fix NullPointerException
  • Refactoring

Version 2.0 (2013-01-19)

  • Enable to trigger a build at node startup

Version 1.1 (2011-02-08)

  • Update the cause and plugin description to Jenkins.

Version 0.1 (2009-12-30)

  • Initial release

35 Comments

  1. Please could you give me some use cases where you need to schedule a build at Jenkins startup?

    1. Use case: Map network drives with the credentials of the user id that runs Jenkins.

      1. This classic use case is not tied to a job but tied to a Jenkins node.
        And for this kind of feature, you can add an initialization Groovy script.
        The Groovy script will be automatically loaded and executed at the Jenkins node startup.

        1. Groovy script?  I think I speak for many others when I say that I have enough languages to worry about as it is, and have no desire to deal with a JVM-specific scripting language that so far I can get away with never having to use. :)

  2. Plugin only works when the master node gets restarted, need to make it work for slave node as well.

    Please could you tell me what needs to be done?

    1. This plugin is aimed at restarting the job at Jenkins startup and not at node startup. What is exactly your need? Maybe put an initialization script or use the ScriptTrigger plugin could meet your needs.

      1. Thanks for response.

        my needs are  i want to run job at node startup not at jenkins startup.

        what i need to put in initialization script?

        1. Ok I understand. Do you want the job starts whatever it is a start of the master or a slave, and/or do you want to have the ability to restrict to some node labels?
          And for my personal information, what is your functional use case?

          1. yes, so basically i have a map drive job, which i need to fire each time when a particular slave starts.

            i have few slaves but i need to run this job for a particular job.

            Thanks,

            Punit

            1. Version 2.0 should meet your needs.

              1. Thanks you, but can you tell me how do i update my plugin to version 2.0, i installed it using plugin manager in jenkins, but it is installing version 1.0, and there was no option to upgrade that to version 2.0, is there any way to installed version 2.0 manually or how do i upgrade?

                Thanks,

                Punit

                1. You can install it manually by downloading it at http://maven.jenkins-ci.org:8081/content/repositories/releases/org/jenkins-ci/plugins/startup-trigger-plugin/2.0/

                  You can install it automatically through the update center mechanism in Jenkins . It takes some time to be available. For now, it should be OK.

  3. I get a NPE after installing v2.0. I already have a job defined which starts a job on the master...
    java.lang.NullPointerException
    at org.jvnet.hudson.plugins.triggers.startup.HudsonComputerListener.onOnline(HudsonComputerListener.java:42)
    at jenkins.model.Jenkins.<init>(Jenkins.java:846)
    at hudson.model.Hudson.<init>(Hudson.java:81)
    at hudson.model.Hudson.<init>(Hudson.java:77)
    at hudson.WebAppMain$2.run(WebAppMain.java:214)
    Seems cause is an empty node textfield. So I could fix it by pathing the config.xml

    Also it seems not to be working on node 'master'?

    1. to make it work on master, leave the Node Label blank, don't put 'master'.

      and for me it worked fine, didn't got any exception.

      Thanks,

      Punit

      1. Ok - got it:

        If I first updated the pulgin, the config.xml contained:
        <triggers class="vector">
        <org.jvnet.hudson.plugins.triggers.startup.HudsonStartupTrigger plugin="startup-trigger-plugin@1.1">
        <spec></spec>
        </org.jvnet.hudson.plugins.triggers.startup.HudsonStartupTrigger>
        </triggers>
        -> this leads to my got exception

        Remove the trigger, update the plugin and reinsert it with master:
        <triggers class="vector">
        <org.jvnet.hudson.plugins.triggers.startup.HudsonStartupTrigger plugin="startup-trigger-plugin@1.1">
        <spec></spec>
        <label>master</label>
        </org.jvnet.hudson.plugins.triggers.startup.HudsonStartupTrigger>
        </triggers>
        -> this is not working, master is not triggered on startup

        But changing to:
        <triggers class="vector">
        <org.jvnet.hudson.plugins.triggers.startup.HudsonStartupTrigger plugin="startup-trigger-plugin@1.1">
        <spec></spec>
        <label></label>
        </org.jvnet.hudson.plugins.triggers.startup.HudsonStartupTrigger>
        </triggers>
        -> this works.

        Thanks

        1. master label should be fixed too in 2.1

          1. 2.1 runs perfect. Thanks for fast fix.

    2. The NullPointerException should be fixed in 2.1.
      Thanks

  4. With Jenkins 1.500 and StartupTrigger 2.0 (and 2.1), the labelled job does not start.

    1. Create a job called "TEST" (check "Build when job nodes start (nodes matching the configured node label)" and type "STARTUP" as Node label)
    2. Put label "STARTUP" to Node
    3. Restart slave called "STARTUP"

    The job does not start and there is with no error...
    => Jenkins logs : no error

    => Slave logs : [StartupTrigger[] - Scanning jobs for slave STARTUPSlave successfully connected and online

    1. Hi,

      did you restart your jenkins after installing startup trigger, this plugin requires restart jenkins.

      FYI:

      if you go to manage jenkins->plugin->updates. it will still point to the older version of this plugin, if u did not restart your jenkins.

      Thanks,

      Punit

      1. Hi,

        I have restarted Jenkins master and the problem persists.

        Is it possible to activate logs to trace config.xml jobs scanning?

        1. At node startup (master/slave), all jobs are scanned.
          If a job is scheduled, a log is printed to node log.

    2. The whole labels string of the node is compared instead of being split and compared with single labels.

      Thus it only works if the whole labels string corresponds.

      Example :

      If a node has labels : WinXP Acceptance London

      The job will be triggered if and only if  Restricted node Label = "WinXP Acceptance London"

      I would expect it to be triggered, for example if   Restricted node Label = London 

      1. Please upgrade to 2.4 version and let me know.
        Thanks

  5. Is the job forced to run in the same node that is starting?

    Example: If I configure a job to run when "Johnson Slave" starts, will the job be executed in "Johnson Slave"? (without setting Restrict where this project can be run)

    What if I'm using labels? Like creating a startup job for "WinXP" label, will the job run in the same label and not in another WinXP slave?

  6. How can I see the logs generated by the plugin? According to this article (https://wiki.jenkins-ci.org/display/JENKINS/Logging), I've set the log recorder to hudson.plugins.triggers.startup on finest

    I restarted a slave to make sure the plugin gets triggered (and it did), but the log did not record anything.

    Running the following code in the jenkins console, I could see that hudson.plugins.triggers.startup. So I don't understand what is wrong. Help me out someone?

    import java.util.logging.*;

    LogManager.getLogManager().getLoggerNames().each() {
      print "$

    Unknown macro: {it}

    , ";
    }

  7. I'd like to create a job which would be triggered on the startup of any node and bring that node online if it has been marked as offline

    1. Will setting "Restricted node Label" to ".*" allow this to run on any node that is restarting, or do I require a separate job for each node?

    2. Assuming can use single job for all nodes, how can I pass the name of the node that is starting through to the "Execute Groovy Script" build step?

        This is the groovy code I have so far:

    jenkins = Hudson.instance
    def node = jenkins.slaves.getNode("node name").getComputer()
    if (node.isTemporarilyOffline())
    { 
        node.setTemporarilyOffline(false, node.getOfflineCause())
    }
    
    1. Ok, wildcards don't work, any chance of getting this plugin to allow wildcards for node label? (alternatively I guess I could give each node I want this job to work for the same label, eg "online"). 

      Of most importance is getting the name of the node that triggered the job into the script, if not current supported is there any chance the plugin can be updated to do that?

  8. Is anyone supporting this plugin, I've raised an issue but had no response.

    1. Yeah, the plugin was up for adoption.  Your issue should be fixed in the latest versions, I'm doing my best to support this on my free time :)

  9. Hi,

    Is it possible to make the triggered job run on the specific instance that is starting?

    I use the label parameter to restrict the triggered job (to WORKER for example). But I might have multiple WORKER nodes and I only want the job to run when this new WORKER node connects.

    1. Yes, you'll want to make sure your job accepts a node label parameter to specify the node it is to run on.  Then provide the plugin with the name of that parameter in the "Node parameter name" field in the advanced settings for the plugin.  Then the plugin will provide the name of the node (which doubles as a label containing only one node) as the job label.  As long as the job is parameterized and has a parameter that accepts the label as input this will work.

      1. Hi, Thanks for the quick reply.

        This doesn't seem to work for me. I have a single "Test" job which takes a Label parameter called "Target" from the NodeLabel plugin.I then configured the plugin to build when nodes with a label of "WORKER" come online. The job also specifies a "Node parameter name" of "Target" (which matches the job parameter name).
        However when those nodes come online and connect to Jenkins nothing happens. 

         

        I'm obviously mis-configuring something?

        1. Actually, I have it working.

          It seems to work when I switch it to "Run on initial connection" instead of "Run when node brought online".
          I possibly misunderstood the purpose of "Run when node brought online"