public Collection<Config> getAllMavenSettingsConfigs() {
   final ExtensionList<MavenSettingsConfigProvider> configProviders =
       Jenkins.getInstance().getExtensionList(MavenSettingsConfigProvider.class);
   if (configProviders != null && configProviders.size() > 0) {
     // there is only one implementation...
     return configProviders.get(0).getAllConfigs();
   }
   return Collections.emptyList();
 }
 public CredentialsSaveableListener getSaveableListener() {
   if (null == saveableListener) {
     ExtensionList<SaveableListener> extensionList =
         Hudson.getInstance().getExtensionList(SaveableListener.class);
     if (null != extensionList && !extensionList.isEmpty()) {
       for (SaveableListener listener : extensionList) {
         if (listener instanceof CredentialsSaveableListener) {
           saveableListener = (CredentialsSaveableListener) listener;
           break;
         }
       }
     }
   }
   return saveableListener;
 }
Beispiel #3
0
 private static <R> Holder<R> findHolder(R referent) {
   if (referent == null) {
     // AbstractBuild.NONE
     return new DefaultHolderFactory.NoHolder<R>();
   }
   for (HolderFactory f : ExtensionList.lookup(HolderFactory.class)) {
     Holder<R> h = f.make(referent);
     if (h != null) {
       LOGGER.log(
           Level.FINE, "created build reference for {0} using {1}", new Object[] {referent, f});
       return h;
     }
   }
   return new DefaultHolderFactory().make(referent);
 }
 private ConfigProvider getConfigProvider() {
     ExtensionList<ConfigProvider> providers = ConfigProvider.all();
     return providers.get(UserDataConfig.UserDataConfigProvider.class);
 }
    public Server provision(JCloudsCloud cloud) {
        final ServerCreateBuilder builder = Builders.server();
        final String nodeName = name + "-" + System.currentTimeMillis() % 1000;
        LOGGER.info("Provisioning new openstack node " + nodeName);
        // Ensure predictable node name so we can inject it into user data
        builder.name(nodeName);

        if (!Strings.isNullOrEmpty(imageId)) {
            LOGGER.info("Setting image id to " + imageId);
            builder.image(imageId);
        }
        if (!Strings.isNullOrEmpty((hardwareId))) {
            LOGGER.info("Setting hardware Id to " + hardwareId);
            builder.flavor(hardwareId);
        }

        if (!Strings.isNullOrEmpty(networkId)) {
            LOGGER.info("Setting network to " + networkId);
            builder.networks(Arrays.asList(networkId));
        }

        if (!Strings.isNullOrEmpty(securityGroups)) {
            LOGGER.info("Setting security groups to " + securityGroups);
            for (String sg: csvToArray(securityGroups)) {
                builder.addSecurityGroup(sg);
            }
        }

        if (!Strings.isNullOrEmpty(keyPairName)) {
            LOGGER.info("Setting keyPairName to " + keyPairName);
            builder.keypairName(keyPairName);
        }

        if (!Strings.isNullOrEmpty(availabilityZone)) {
            LOGGER.info("Setting availabilityZone to " + availabilityZone);
            builder.availabilityZone(availabilityZone);
        }

        ExtensionList<ConfigProvider> providers = ConfigProvider.all();
        UserDataConfig.UserDataConfigProvider myProvider = providers.get(UserDataConfig.UserDataConfigProvider.class);
        Config userData = myProvider.getConfigById(userDataId);
        if (userData != null && !userData.content.isEmpty()) {
            HashMap<String, String> vars = new HashMap<String, String>();
            String rootUrl = Jenkins.getInstance().getRootUrl();
            vars.put("JENKINS_URL", rootUrl);
            vars.put("SLAVE_JAR_URL", rootUrl + "jnlpJars/slave.jar");
            vars.put("SLAVE_JNLP_URL", rootUrl + "computer/" + nodeName + "/slave-agent.jnlp");
            vars.put("SLAVE_LABELS", labelString);
            String content = Util.replaceMacro(userData.content, vars);
            LOGGER.info("Sending user-data:\n" + content);
            builder.userData(Base64.encode(content.getBytes()));
        }

        final Openstack openstack = cloud.getOpenstack();
        final Server server = openstack.bootAndWaitActive(builder, cloud.startTimeout);
        LOGGER.info("Provisioned: " + server.toString());

        if (cloud.isFloatingIps()) {
            LOGGER.info("Assiging floating IP to " + nodeName);
            openstack.assignFloatingIp(server);
        }

        // Make sure address information is propagated
        return openstack.updateInfo(server);
    }
 /** All registered {@link QueueTaskDispatcher}s. */
 public static ExtensionList<QueueTaskDispatcher> all() {
   return ExtensionList.lookup(QueueTaskDispatcher.class);
 }
Beispiel #7
0
 @Initializer(after = InitMilestone.JOB_LOADED)
 public static void init() {
   ExtensionList.lookup(Uptime.class).get(0).startTime = System.currentTimeMillis();
 }
 public static ExtensionList<StepExecutionIterator> all() {
   return ExtensionList.lookup(StepExecutionIterator.class);
 }
 /** Returns all the registered {@link ChangeLogAnnotator} descriptors. */
 public static ExtensionList<ChangeLogAnnotator> all() {
   return ExtensionList.lookup(ChangeLogAnnotator.class);
 }