当前位置: 首页>>代码示例>>Java>>正文


Java Config类代码示例

本文整理汇总了Java中org.jenkinsci.lib.configprovider.model.Config的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Config类属于org.jenkinsci.lib.configprovider.model包,在下文中一共展示了Config类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDefaultJenkinsFile

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
@Test
public void testDefaultJenkinsFile() throws Exception {
    GlobalConfigFiles globalConfigFiles = r.jenkins.getExtensionList(GlobalConfigFiles.class).get(GlobalConfigFiles.class);
    ConfigFileStore store = globalConfigFiles.get();

    Config config = new GroovyScript("Jenkinsfile", "Jenkinsfile", "",
        "semaphore 'wait'; node {checkout scm; echo readFile('file')}");
    store.save(config);

    sampleGitRepo.init();
    sampleGitRepo.write("file", "initial content");
    sampleGitRepo.git("commit", "--all", "--message=flow");
    WorkflowMultiBranchProject mp = r.jenkins.createProject(PipelineMultiBranchDefaultsProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleGitRepo.toString(), "", "*", "", false),
        new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    WorkflowJob p = PipelineMultiBranchDefaultsProjectTest.scheduleAndFindBranchProject(mp, "master");
    SemaphoreStep.waitForStart("wait/1", null);
    WorkflowRun b1 = p.getLastBuild();
    assertNotNull(b1);
    assertEquals(1, b1.getNumber());
    SemaphoreStep.success("wait/1", null);
    r.assertLogContains("initial content", r.waitForCompletion(b1));
}
 
开发者ID:vaimr,项目名称:pipeline-multibranch-defaults-plugin,代码行数:24,代码来源:DefaultsBinderTest.java

示例2: create

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
@Override
public FlowExecution create(FlowExecutionOwner handle, TaskListener listener, List<? extends Action> actions) throws Exception {
    Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        throw new IllegalStateException("inappropriate context");
    }
    Queue.Executable exec = handle.getExecutable();
    if (!(exec instanceof WorkflowRun)) {
        throw new IllegalStateException("inappropriate context");
    }

    ConfigFileStore store = GlobalConfigFiles.get();
    if (store != null) {
        Config config = store.getById(PipelineBranchDefaultsProjectFactory.SCRIPT);
        if (config != null) {
            return new CpsFlowDefinition(config.content, false).create(handle, listener, actions);
        }
    }
    throw new IllegalArgumentException("Default " + PipelineBranchDefaultsProjectFactory.SCRIPT + " not found. Check configuration.");
}
 
开发者ID:vaimr,项目名称:pipeline-multibranch-defaults-plugin,代码行数:21,代码来源:DefaultsBinder.java

示例3: testDefaultJenkinsFileLoadFromWorkspace

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
@Test
public void testDefaultJenkinsFileLoadFromWorkspace() throws Exception {
    GlobalConfigFiles globalConfigFiles = r.jenkins.getExtensionList(GlobalConfigFiles.class).get(GlobalConfigFiles.class);
    ConfigFileStore store = globalConfigFiles.get();
    Config config = new GroovyScript("Jenkinsfile", "Jenkinsfile", "",
        "semaphore 'wait'; node {checkout scm; load 'Jenkinsfile'}");
    store.save(config);


    sampleGitRepo.init();
    sampleGitRepo.write("Jenkinsfile", "echo readFile('file')");
    sampleGitRepo.git("add", "Jenkinsfile");
    sampleGitRepo.write("file", "initial content");
    sampleGitRepo.git("commit", "--all", "--message=flow");
    WorkflowMultiBranchProject mp = r.jenkins.createProject(PipelineMultiBranchDefaultsProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleGitRepo.toString(), "", "*", "", false),
        new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    WorkflowJob p = PipelineMultiBranchDefaultsProjectTest.scheduleAndFindBranchProject(mp, "master");
    SemaphoreStep.waitForStart("wait/1", null);
    WorkflowRun b1 = p.getLastBuild();
    assertNotNull(b1);
    assertEquals(1, b1.getNumber());
    SemaphoreStep.success("wait/1", null);
    r.assertLogContains("initial content", r.waitForCompletion(b1));
}
 
开发者ID:vaimr,项目名称:pipeline-multibranch-defaults-plugin,代码行数:26,代码来源:DefaultsBinderTest.java

示例4: doFillMavenSettingsConfigItems

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
@Restricted(NoExternalUse.class) // Only for UI calls
public ListBoxModel doFillMavenSettingsConfigItems(@AncestorInPath ItemGroup context) {
    ListBoxModel r = new ListBoxModel();
    r.add("--- Use system default settings or file path ---",null);
    for (Config config : ConfigFiles.getConfigsInContext(context, MavenSettingsConfigProvider.class)) {
        r.add(config.name, config.id);
    }
    return r;
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:10,代码来源:WithMavenStep.java

示例5: doFillGlobalMavenSettingsConfigItems

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
@Restricted(NoExternalUse.class) // Only for UI calls
public ListBoxModel doFillGlobalMavenSettingsConfigItems(@AncestorInPath ItemGroup context) {
    ListBoxModel r = new ListBoxModel();
    r.add("--- Use system default settings or file path ---",null);
    for (Config config : ConfigFiles.getConfigsInContext(context, GlobalMavenSettingsConfigProvider.class)) {
        r.add(config.name, config.id);
    }
    return r;
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:10,代码来源:WithMavenStep.java

示例6: configFile

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
@Issue("JENKINS-27152")
@Test public void configFile() throws Exception {
    story.addStep(new Statement() {
        @Override public void evaluate() throws Throwable {
            DockerTestUtil.assumeDocker();
            ConfigProvider configProvider = story.j.jenkins.getExtensionList(ConfigProvider.class).get(CustomConfig.CustomConfigProvider.class);
            String id = configProvider.getProviderId() + "myfile";
            Config config = new CustomConfig(id, "My File", "", "some-content");
            configProvider.save(config);
            WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj");
            p.setDefinition(new CpsFlowDefinition(
                "node {\n" +
                "  withDockerContainer('ubuntu') {\n" +
                    "  wrap([$class: 'ConfigFileBuildWrapper', managedFiles: [[fileId: '" + config.id + "', variable: 'FILE']]]) {\n" +
                    "    sh 'cat $FILE'\n" +
                    "  }\n" +
                "  }\n" +
                "  wrap([$class: 'ConfigFileBuildWrapper', managedFiles: [[fileId: '" + config.id + "', variable: 'FILE']]]) {\n" +
                "    withDockerContainer('ubuntu') {\n" +
                "      sh 'tr \"a-z\" \"A-Z\" < $FILE'\n" +
                "    }\n" +
                "  }\n" +
                "}", true));
            WorkflowRun b = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
            story.j.assertLogContains("some-content", b);
            story.j.assertLogContains("SOME-CONTENT", b);
        }
    });
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:30,代码来源:WithContainerStepTest.java

示例7: settingsFromConfig

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
/**
 * Reads the config file from Config File Provider, expands the credentials and stores it in a file on the temp
 * folder to use it with the maven wrapper script
 *
 * @param mavenSettingsConfigId config file id from Config File Provider
 * @param mavenSettingsFile     path to write te content to
 * @param credentials
 * @return the {@link FilePath} to the settings file
 * @throws AbortException in case of error
 */
private void settingsFromConfig(String mavenSettingsConfigId, FilePath mavenSettingsFile, @Nonnull Collection<Credentials> credentials) throws AbortException {

    Config c = ConfigFiles.getByIdOrNull(build, mavenSettingsConfigId);
    if (c == null) {
        throw new AbortException("Could not find the Maven settings.xml config file id:" + mavenSettingsConfigId + ". Make sure it exists on Managed Files");
    }
    if (StringUtils.isBlank(c.content)) {
        throw new AbortException("Could not create Maven settings.xml config file id:" + mavenSettingsConfigId + ". Content of the file is empty");
    }

    MavenSettingsConfig mavenSettingsConfig;
    if (c instanceof MavenSettingsConfig) {
        mavenSettingsConfig = (MavenSettingsConfig) c;
    } else {
        mavenSettingsConfig = new MavenSettingsConfig(c.id, c.name, c.comment, c.content, MavenSettingsConfig.isReplaceAllDefault, null);
    }

    try {

        // JENKINS-43787 handle null
        final List<ServerCredentialMapping> serverCredentialMappings = Objects.firstNonNull(mavenSettingsConfig.getServerCredentialMappings(), Collections.<ServerCredentialMapping>emptyList());

        final Map<String, StandardUsernameCredentials> resolvedCredentials = CredentialsHelper.resolveCredentials(build, serverCredentialMappings);

        credentials.addAll(resolvedCredentials.values());

        String mavenSettingsFileContent;
        if (resolvedCredentials.isEmpty()) {
            mavenSettingsFileContent = mavenSettingsConfig.content;
            console.println("[withMaven] use Maven settings.xml '" + mavenSettingsConfig.id + "' with NO Maven servers credentials provided by Jenkins");
        } else {
            List<String> tempFiles = new ArrayList<String>();
            mavenSettingsFileContent = CredentialsHelper.fillAuthentication(mavenSettingsConfig.content, mavenSettingsConfig.isReplaceAll, resolvedCredentials, tempBinDir, tempFiles);
            console.println("[withMaven] use Maven settings.xml '" + mavenSettingsConfig.id + "' with Maven servers credentials provided by Jenkins " +
                    "(replaceAll: " + mavenSettingsConfig.isReplaceAll + "): " +
                    Joiner.on(", ").skipNulls().join(Iterables.transform(resolvedCredentials.entrySet(), new MavenServerToCredentialsMappingToStringFunction())));
        }

        mavenSettingsFile.write(mavenSettingsFileContent, getComputer().getDefaultCharset().name());
    } catch (Exception e) {
        throw new IllegalStateException("Exception injecting Maven settings.xml " + mavenSettingsConfig.id +
                " during the build: " + build + ": " + e.getMessage(), e);
    }
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:55,代码来源:WithMavenStepExecution.java

示例8: globalSettingsFromConfig

import org.jenkinsci.lib.configprovider.model.Config; //导入依赖的package包/类
/**
 * Reads the global config file from Config File Provider, expands the credentials and stores it in a file on the temp
 * folder to use it with the maven wrapper script
 *
 * @param mavenGlobalSettingsConfigId global config file id from Config File Provider
 * @param mavenGlobalSettingsFile     path to write te content to
 * @param credentials
 * @return the {@link FilePath} to the settings file
 * @throws AbortException in case of error
 */
private void globalSettingsFromConfig(String mavenGlobalSettingsConfigId, FilePath mavenGlobalSettingsFile, Collection<Credentials> credentials) throws AbortException {

    Config c = ConfigFiles.getByIdOrNull(build, mavenGlobalSettingsConfigId);
    if (c == null) {
        throw new AbortException("Could not find the Maven global settings.xml config file id:" + mavenGlobalSettingsFile + ". Make sure it exists on Managed Files");
    }
    if (StringUtils.isBlank(c.content)) {
        throw new AbortException("Could not create Maven global settings.xml config file id:" + mavenGlobalSettingsFile + ". Content of the file is empty");
    }

    GlobalMavenSettingsConfig mavenGlobalSettingsConfig;
    if (c instanceof GlobalMavenSettingsConfig) {
        mavenGlobalSettingsConfig = (GlobalMavenSettingsConfig) c;
    } else {
        mavenGlobalSettingsConfig = new GlobalMavenSettingsConfig(c.id, c.name, c.comment, c.content, MavenSettingsConfig.isReplaceAllDefault, null);
    }

    try {
        // JENKINS-43787 handle null
        final List<ServerCredentialMapping> serverCredentialMappings = Objects.firstNonNull(mavenGlobalSettingsConfig.getServerCredentialMappings(), Collections.<ServerCredentialMapping>emptyList());

        final Map<String, StandardUsernameCredentials> resolvedCredentials = CredentialsHelper.resolveCredentials(build, serverCredentialMappings);

        credentials.addAll(resolvedCredentials.values());

        String mavenGlobalSettingsFileContent;
        if (resolvedCredentials.isEmpty()) {
            mavenGlobalSettingsFileContent = mavenGlobalSettingsConfig.content;
            console.println("[withMaven] use Maven global settings.xml '" + mavenGlobalSettingsConfig.id + "' with NO Maven servers credentials provided by Jenkins");

        } else {
            List<String> tempFiles = new ArrayList<String>();
            mavenGlobalSettingsFileContent = CredentialsHelper.fillAuthentication(mavenGlobalSettingsConfig.content, mavenGlobalSettingsConfig.isReplaceAll, resolvedCredentials, tempBinDir, tempFiles);
            console.println("[withMaven] use Maven global settings.xml '" + mavenGlobalSettingsConfig.id + "' with Maven servers credentials provided by Jenkins " +
                    "(replaceAll: " + mavenGlobalSettingsConfig.isReplaceAll + "): " +
                    Joiner.on(", ").skipNulls().join(Iterables.transform(resolvedCredentials.entrySet(), new MavenServerToCredentialsMappingToStringFunction())));

        }


        mavenGlobalSettingsFile.write(mavenGlobalSettingsFileContent, getComputer().getDefaultCharset().name());
        LOGGER.log(Level.FINE, "Created global config file {0}", new Object[]{mavenGlobalSettingsFile});
    } catch (Exception e) {
        throw new IllegalStateException("Exception injecting Maven settings.xml " + mavenGlobalSettingsConfig.id +
                " during the build: " + build + ": " + e.getMessage(), e);
    }
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:58,代码来源:WithMavenStepExecution.java


注:本文中的org.jenkinsci.lib.configprovider.model.Config类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。