Search in sources :

Example 1 with Initializer

use of hudson.init.Initializer in project hudson-2.x by hudson.

the class InitialUserContent method init.

@Initializer(after = JOB_LOADED)
public static void init(Hudson h) throws IOException {
    File userContentDir = new File(h.getRootDir(), "userContent");
    if (!userContentDir.exists()) {
        userContentDir.mkdirs();
        FileUtils.writeStringToFile(new File(userContentDir, "readme.txt"), Messages.Hudson_USER_CONTENT_README());
    }
}
Also used : File(java.io.File) Initializer(hudson.init.Initializer)

Example 2 with Initializer

use of hudson.init.Initializer in project hudson-2.x by hudson.

the class Trigger method init.

@Initializer(after = JOB_LOADED)
public static void init() {
    new DoubleLaunchChecker().schedule();
    // start all PeridocWorks
    for (PeriodicWork p : PeriodicWork.all()) timer.scheduleAtFixedRate(p, p.getInitialDelay(), p.getRecurrencePeriod());
    // start monitoring nodes, although there's no hurry.
    timer.schedule(new SafeTimerTask() {

        public void doRun() {
            ComputerSet.initialize();
        }
    }, 1000 * 10);
}
Also used : DoubleLaunchChecker(hudson.util.DoubleLaunchChecker) PeriodicWork(hudson.model.PeriodicWork) Initializer(hudson.init.Initializer)

Example 3 with Initializer

use of hudson.init.Initializer in project hudson-2.x by hudson.

the class GroovyInitScript method init.

@Initializer(after = JOB_LOADED)
public static void init(Hudson h) throws IOException {
    URL bundledInitScript = h.servletContext.getResource("/WEB-INF/init.groovy");
    if (bundledInitScript != null) {
        LOGGER.info("Executing bundled init script: " + bundledInitScript);
        execute(new GroovyCodeSource(bundledInitScript));
    }
    File initScript = new File(h.getRootDir(), "init.groovy");
    if (initScript.exists()) {
        LOGGER.info("Executing " + initScript);
        execute(new GroovyCodeSource(initScript));
    }
}
Also used : GroovyCodeSource(groovy.lang.GroovyCodeSource) File(java.io.File) URL(java.net.URL) Initializer(hudson.init.Initializer)

Example 4 with Initializer

use of hudson.init.Initializer in project hudson-2.x by hudson.

the class QueueSorter method installDefaultQueueSorter.

/**
     * Installs the default queue sorter.
     *
     * {@link Queue#Queue(hudson.model.LoadBalancer)} is too early to do this
     */
@Initializer(after = JOB_LOADED)
public static void installDefaultQueueSorter() {
    ExtensionList<QueueSorter> all = all();
    if (all.isEmpty())
        return;
    Queue q = Hudson.getInstance().getQueue();
    // someone has already installed something. leave that alone.
    if (q.getSorter() != null)
        return;
    q.setSorter(all.get(0));
    if (all.size() > 1)
        LOGGER.warning("Multiple QueueSorters are registered. Only the first one is used and the rest are ignored: " + all);
}
Also used : Queue(hudson.model.Queue) Initializer(hudson.init.Initializer)

Aggregations

Initializer (hudson.init.Initializer)4 File (java.io.File)2 GroovyCodeSource (groovy.lang.GroovyCodeSource)1 PeriodicWork (hudson.model.PeriodicWork)1 Queue (hudson.model.Queue)1 DoubleLaunchChecker (hudson.util.DoubleLaunchChecker)1 URL (java.net.URL)1