Esempio n. 1
0
 public PluggableSCMMaterial(PluggableSCMMaterialConfig config) {
   this();
   this.name = config.getName();
   this.scmId = config.getScmId();
   this.scmConfig = config.getSCMConfig();
   this.folder = config.getFolder();
   this.filter = config.filter();
 }
Esempio n. 2
0
  @Test
  public void shouldReadFolderAndFilterForPluggableSCMMaterialConfig() throws Exception {
    String xml =
        "<cruise schemaVersion='"
            + GoConstants.CONFIG_SCHEMA_VERSION
            + "'>\n"
            + "<scms>\n"
            + "    <scm id='scm-id' name='scm-name'>\n"
            + "		<pluginConfiguration id='plugin-id' version='1.0'/>\n"
            + "      <configuration>\n"
            + "        <property>\n"
            + "          <key>url</key>\n"
            + "          <value>http://go</value>\n"
            + "        </property>\n"
            + "      </configuration>\n"
            + "    </scm>\n"
            + "  </scms>"
            + "<pipelines group=\"group_name\">\n"
            + "  <pipeline name=\"new_name\">\n"
            + "    <materials>\n"
            + "      <scm ref='scm-id' dest='dest'>\n"
            + "            <filter>\n"
            + "                <ignore pattern=\"x\"/>\n"
            + "                <ignore pattern=\"y\"/>\n"
            + "            </filter>\n"
            + "      </scm>\n"
            + "    </materials>\n"
            + "    <stage name=\"stage_name\">\n"
            + "      <jobs>\n"
            + "        <job name=\"job_name\" />\n"
            + "      </jobs>\n"
            + "    </stage>\n"
            + "  </pipeline>\n"
            + "</pipelines></cruise>";

    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(xml);
    PipelineConfig pipelineConfig =
        goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("new_name"));
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig =
        (PluggableSCMMaterialConfig) pipelineConfig.materialConfigs().get(0);
    assertThat(
        pluggableSCMMaterialConfig.getSCMConfig(), is(goConfigHolder.config.getSCMs().get(0)));
    assertThat(pluggableSCMMaterialConfig.getFolder(), is("dest"));
    assertThat(
        pluggableSCMMaterialConfig.filter(),
        is(new Filter(new IgnoredFiles("x"), new IgnoredFiles("y"))));
  }
 private PipelineConfig setupPipelineWithScmMaterial(
     String pipelineName, String stageName, String jobName) {
   PluggableSCMMaterialConfig pluggableSCMMaterialConfig =
       MaterialConfigsMother.pluggableSCMMaterialConfigWithConfigProperties("url", "password");
   SCMPropertyConfiguration configuration = new SCMPropertyConfiguration();
   configuration.add(
       new SCMProperty("url", null).with(PackageConfiguration.PART_OF_IDENTITY, true));
   configuration.add(
       new SCMProperty("password", null).with(PackageConfiguration.PART_OF_IDENTITY, false));
   SCMMetadataStore.getInstance()
       .addMetadataFor(
           pluggableSCMMaterialConfig.getPluginId(), new SCMConfigurations(configuration), null);
   PipelineConfig pipelineConfig =
       PipelineConfigMother.pipelineConfig(
           pipelineName, stageName, new MaterialConfigs(pluggableSCMMaterialConfig), jobName);
   configHelper.addSCMConfig(pluggableSCMMaterialConfig.getSCMConfig());
   configHelper.addPipeline(pipelineConfig);
   return pipelineConfig;
 }
Esempio n. 4
0
  @Test
  public void shouldBeAbleToResolveSecureConfigPropertiesForSCMs() throws Exception {
    String encryptedValue = new GoCipher().encrypt("secure-two");
    String xml =
        "<cruise schemaVersion='"
            + GoConstants.CONFIG_SCHEMA_VERSION
            + "'>\n"
            + "<scms>\n"
            + "    <scm id='scm-id' name='name'>\n"
            + "		<pluginConfiguration id='plugin-id' version='1.0'/>\n"
            + "      <configuration>\n"
            + "        <property>\n"
            + "          <key>plain</key>\n"
            + "          <value>value</value>\n"
            + "        </property>\n"
            + "        <property>\n"
            + "          <key>secure-one</key>\n"
            + "          <value>secure-value</value>\n"
            + "        </property>\n"
            + "        <property>\n"
            + "          <key>secure-two</key>\n"
            + "          <encryptedValue>"
            + encryptedValue
            + "</encryptedValue>\n"
            + "        </property>\n"
            + "      </configuration>\n"
            + "    </scm>\n"
            + "  </scms>"
            + "<pipelines group=\"group_name\">\n"
            + "  <pipeline name=\"new_name\">\n"
            + "    <materials>\n"
            + "      <scm ref='scm-id' />\n"
            + "    </materials>\n"
            + "    <stage name=\"stage_name\">\n"
            + "      <jobs>\n"
            + "        <job name=\"job_name\" />\n"
            + "      </jobs>\n"
            + "    </stage>\n"
            + "  </pipeline>\n"
            + "</pipelines></cruise>";

    // meta data of scm
    SCMPropertyConfiguration scmConfiguration = new SCMPropertyConfiguration();
    scmConfiguration.add(new SCMProperty("plain"));
    scmConfiguration.add(new SCMProperty("secure-one").with(SCMConfiguration.SECURE, true));
    scmConfiguration.add(new SCMProperty("secure-two").with(SCMConfiguration.SECURE, true));
    SCMMetadataStore.getInstance()
        .addMetadataFor("plugin-id", new SCMConfigurations(scmConfiguration), null);

    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(xml);
    SCM scmConfig = goConfigHolder.config.getSCMs().first();
    PipelineConfig pipelineConfig =
        goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("new_name"));
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig =
        (PluggableSCMMaterialConfig) pipelineConfig.materialConfigs().get(0);
    assertThat(pluggableSCMMaterialConfig.getSCMConfig(), is(scmConfig));
    Configuration configuration = pluggableSCMMaterialConfig.getSCMConfig().getConfiguration();
    assertThat(configuration.get(0).getConfigurationValue().getValue(), is("value"));
    assertThat(
        configuration.get(1).getEncryptedValue().getValue(),
        is(new GoCipher().encrypt("secure-value")));
    assertThat(configuration.get(2).getEncryptedValue().getValue(), is(encryptedValue));
  }