hudson.init.Initializer Java Examples
The following examples show how to use
hudson.init.Initializer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockerSwarmCloud.java From docker-swarm-plugin with MIT License | 6 votes |
@Initializer(after = InitMilestone.JOB_LOADED) public static void initFromYaml() throws IOException { File configsDir = new File(Jenkins.getInstance().getRootDir(), "pluginConfigs"); File swarmConfigYaml = new File(configsDir, "swarm.yml"); if (swarmConfigYaml.exists()) { LOGGER.info("Configuring swarm plugin from " + swarmConfigYaml.getAbsolutePath()); ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); try (InputStream in = new BufferedInputStream(new FileInputStream(swarmConfigYaml))) { DockerSwarmCloud configuration = mapper.readValue(in, DockerSwarmCloud.class); DockerSwarmCloud existingCloud = DockerSwarmCloud.get(); if (existingCloud != null) { Jenkins.getInstance().clouds.remove(existingCloud); } Jenkins.getInstance().clouds.add(configuration); } } scheduleReaperActor(); scheduleResetStuckBuildsActor(); }
Example #2
Source File: GitTool.java From git-client-plugin with MIT License | 6 votes |
@Initializer(after=EXTENSIONS_AUGMENTED) public static void onLoaded() { //Creates default tool installation if needed. Uses "git" or migrates data from previous versions Jenkins jenkinsInstance = Jenkins.getInstance(); DescriptorImpl descriptor = (DescriptorImpl) jenkinsInstance.getDescriptor(GitTool.class); GitTool[] installations = getInstallations(descriptor); if (installations != null && installations.length > 0) { //No need to initialize if there's already something return; } String defaultGitExe = isWindows() ? "git.exe" : "git"; GitTool tool = new GitTool(DEFAULT, defaultGitExe, Collections.<ToolProperty<?>>emptyList()); descriptor.setInstallations(new GitTool[] { tool }); descriptor.save(); }
Example #3
Source File: BackwardCompatibility.java From lockable-resources-plugin with MIT License | 6 votes |
@Initializer(after = InitMilestone.JOB_LOADED) public static void compatibilityMigration() { LOG.log(Level.FINE, "lockable-resource-plugin compatibility migration task run"); List<LockableResource> resources = LockableResourcesManager.get().getResources(); for (LockableResource resource : resources) { List<StepContext> queuedContexts = resource.getQueuedContexts(); if (!queuedContexts.isEmpty()) { for (StepContext queuedContext : queuedContexts) { List<String> resourcesNames = new ArrayList<>(); resourcesNames.add(resource.getName()); LockableResourcesStruct resourceHolder = new LockableResourcesStruct(resourcesNames, "", 0); LockableResourcesManager.get().queueContext(queuedContext, Arrays.asList(resourceHolder), resource.getName(), null); } queuedContexts.clear(); } } }
Example #4
Source File: GitLabConnection.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
@Initializer(after = InitMilestone.PLUGINS_STARTED) public static void migrate() throws IOException { GitLabConnectionConfig descriptor = (GitLabConnectionConfig) Jenkins.get().getDescriptor(GitLabConnectionConfig.class); if (descriptor == null) return; for (GitLabConnection connection : descriptor.getConnections()) { if (connection.apiTokenId == null && connection.apiToken != null) { for (CredentialsStore credentialsStore : CredentialsProvider.lookupStores(Jenkins.getInstance())) { if (credentialsStore instanceof SystemCredentialsProvider.StoreImpl) { List<Domain> domains = credentialsStore.getDomains(); connection.apiTokenId = UUID.randomUUID().toString(); credentialsStore.addCredentials(domains.get(0), new GitLabApiTokenImpl(CredentialsScope.SYSTEM, connection.apiTokenId, "GitLab API Token", Secret.fromString(connection.apiToken))); } } } } descriptor.save(); }
Example #5
Source File: GitLabIcons.java From gitlab-branch-source-plugin with MIT License | 5 votes |
@Initializer public static void initialize() { addIcon(ICON_GITLAB); addIcon(ICON_PROJECT); addIcon(ICON_BRANCH); addIcon(ICON_COMMIT); addIcon(ICON_MR); addIcon(ICON_TAG); }
Example #6
Source File: GitLabSCMIcons.java From gitlab-branch-source-plugin with GNU General Public License v2.0 | 5 votes |
@Initializer public static void initialize() { addIcon(ICON_GITLAB); addIcon(ICON_PROJECT); addIcon(ICON_BRANCH); addIcon(ICON_COMMIT); addIcon(ICON_MERGE_REQUEST); addIcon(ICON_TAG); }
Example #7
Source File: GitLabSCMWebHook.java From gitlab-branch-source-plugin with GNU General Public License v2.0 | 5 votes |
@Initializer(after = InitMilestone.JOB_LOADED) public static void initialize() { new Thread(new Runnable() { @Override public void run() { ACL.impersonate(ACL.SYSTEM, new ListenerInitializerTask(GitLabSCMWebHook.get())); } }).start(); }
Example #8
Source File: KubernetesCloud.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
@Initializer(before = InitMilestone.PLUGINS_STARTED) public static void addAliases() { Jenkins.XSTREAM2.addCompatibilityAlias( "org.csanchez.jenkins.plugins.kubernetes.OpenShiftBearerTokenCredentialImpl", org.jenkinsci.plugins.kubernetes.credentials.OpenShiftBearerTokenCredentialImpl.class); Jenkins.XSTREAM2.addCompatibilityAlias( "org.csanchez.jenkins.plugins.kubernetes.OpenShiftTokenCredentialImpl", StringCredentialsImpl.class); Jenkins.XSTREAM2.addCompatibilityAlias("org.csanchez.jenkins.plugins.kubernetes.ServiceAccountCredential", org.jenkinsci.plugins.kubernetes.credentials.FileSystemServiceAccountCredential.class); }
Example #9
Source File: BranchListView.java From multi-branch-project-plugin with MIT License | 4 votes |
/** * Gives this class an alias for configuration XML. */ @SuppressWarnings(UNUSED) @Initializer(before = InitMilestone.PLUGINS_STARTED) public static void registerXStream() { Items.XSTREAM.alias("branch-list-view", BranchListView.class); }
Example #10
Source File: IssuesRecorder.java From warnings-ng-plugin with MIT License | 4 votes |
/** Retain backward compatibility. */ @Initializer(before = InitMilestone.PLUGINS_STARTED) public static void addAliases() { Run.XSTREAM2.addCompatibilityAlias("io.jenkins.plugins.analysis.core.views.ResultAction", ResultAction.class); }
Example #11
Source File: PluginImpl.java From zulip-plugin with MIT License | 4 votes |
@Initializer(before = InitMilestone.PLUGINS_STARTED) public static void addAliases() { Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.humbug.HumbugNotifier", ZulipNotifier.class); }
Example #12
Source File: RequestContextFilter.java From audit-log-plugin with MIT License | 4 votes |
/** * Registering the filter */ @Initializer public static void init() throws ServletException { PluginServletFilter.addFilter(new RequestContextFilter()); }
Example #13
Source File: ResteasyGitLabClientBuilder.java From gitlab-plugin with GNU General Public License v2.0 | 4 votes |
@Initializer(before = InitMilestone.PLUGINS_STARTED) public static void setRuntimeDelegate() { RuntimeDelegate.setInstance(new ResteasyProviderFactory()); }
Example #14
Source File: MavenMultiBranchProject.java From multi-branch-project-plugin with MIT License | 4 votes |
/** * Gives this class an alias for configuration XML. */ @Initializer(before = InitMilestone.PLUGINS_STARTED) @SuppressWarnings(UNUSED) public static void registerXStream() { Items.XSTREAM.alias("maven-multi-branch-project", MavenMultiBranchProject.class); }
Example #15
Source File: FreeStyleMultiBranchProject.java From multi-branch-project-plugin with MIT License | 4 votes |
/** * Gives this class an alias for configuration XML. */ @Initializer(before = InitMilestone.PLUGINS_STARTED) @SuppressWarnings("unused") public static void registerXStream() { Items.XSTREAM.alias("freestyle-multi-branch-project", FreeStyleMultiBranchProject.class); }
Example #16
Source File: IvyMultiBranchProject.java From multi-branch-project-plugin with MIT License | 4 votes |
/** * Gives this class an alias for configuration XML. */ @SuppressWarnings(UNUSED) @Initializer(before = InitMilestone.PLUGINS_STARTED) public static void registerXStream() { Items.XSTREAM.alias("ivy-multi-branch-project", IvyMultiBranchProject.class); }
Example #17
Source File: MatrixMultiBranchProject.java From multi-branch-project-plugin with MIT License | 4 votes |
/** * Gives this class an alias for configuration XML. */ @Initializer(before = InitMilestone.PLUGINS_STARTED) @SuppressWarnings(UNUSED) public static void registerXStream() { Items.XSTREAM.alias("matrix-multi-branch-project", MatrixMultiBranchProject.class); }
Example #18
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 4 votes |
@Initializer(before = InitMilestone.PLUGINS_STARTED) public static void addAliases() { XSTREAM2.addCompatibilityAlias("org.jenkinsci.plugins.github_branch_source.OriginGitHubSCMSource", GitHubSCMSource.class); }
Example #19
Source File: JwtAuthenticationFilter.java From blueocean-plugin with MIT License | 4 votes |
@Initializer(fatal=false) public static void init() throws ServletException { PluginServletFilter.addFilter(new JwtAuthenticationFilter()); }
Example #20
Source File: BuildStatusConfig.java From github-autostatus-plugin with MIT License | 4 votes |
/** * Adds compatibility aliases to prevent "old data" warnings. */ @Initializer(before = InitMilestone.PLUGINS_STARTED) public static void addCompatibilityAliases() { XSTREAM2.addCompatibilityAlias("org.jenkinsci.plugins.githubautostatus.BuildStageModel", BuildStage.class); XSTREAM2.addCompatibilityAlias("org.jenkinsci.plugins.githubautostatus.notifiers.BuildState", BuildState.class); }
Example #21
Source File: ConfigurationAsCode.java From configuration-as-code-plugin with MIT License | 3 votes |
/** * Defaults to use a file in the current working directory with the name 'jenkins.yaml' * * Add the environment variable CASC_JENKINS_CONFIG to override the default. Accepts single file or a directory. * If a directory is detected, we scan for all .yml and .yaml files * * @throws Exception when the file provided cannot be found or parsed */ @Restricted(NoExternalUse.class) @Initializer(after = InitMilestone.SYSTEM_CONFIG_LOADED, before = InitMilestone.SYSTEM_CONFIG_ADAPTED) public static void init() throws Exception { detectVaultPluginMissing(); get().configure(); }