Пример #1
0
 @Override
 public Map<String, Object> getAttributes(boolean addSecureFields) {
   Map<String, Object> materialMap = new HashMap<>();
   materialMap.put("type", "scm");
   materialMap.put("plugin-id", getPluginId());
   Map<String, String> configurationMap =
       scmConfig.getConfiguration().getConfigurationAsMap(addSecureFields);
   materialMap.put("scm-configuration", configurationMap);
   return materialMap;
 }
Пример #2
0
  @Override
  public void populateEnvironmentContext(
      EnvironmentVariableContext context, MaterialRevision materialRevision, File workingDir) {
    context.setProperty(
        getEnvironmentVariableKey("GO_SCM_%s_%s", "LABEL"),
        materialRevision.getRevision().getRevision(),
        false);
    for (ConfigurationProperty configurationProperty : scmConfig.getConfiguration()) {
      context.setProperty(
          getEnvironmentVariableKey(
              "GO_SCM_%s_%s", configurationProperty.getConfigurationKey().getName()),
          configurationProperty.getValue(),
          configurationProperty.isSecure());
    }
    HashMap<String, String> additionalData =
        materialRevision.getLatestModification().getAdditionalDataMap();
    if (additionalData != null) {
      for (Map.Entry<String, String> entry : additionalData.entrySet()) {
        boolean isSecure = false;
        for (EnvironmentVariableContext.EnvironmentVariable secureEnvironmentVariable :
            context.getSecureEnvironmentVariables()) {
          String urlEncodedValue = null;
          try {
            urlEncodedValue = URLEncoder.encode(secureEnvironmentVariable.value(), "UTF-8");
          } catch (UnsupportedEncodingException e) {
          }
          boolean isSecureEnvironmentVariableEncoded =
              !StringUtil.isBlank(urlEncodedValue)
                  && !secureEnvironmentVariable.value().equals(urlEncodedValue);
          if (isSecureEnvironmentVariableEncoded && entry.getValue().contains(urlEncodedValue)) {
            isSecure = true;
            break;
          }
        }

        String key = entry.getKey();
        String value = entry.getValue();
        context.setProperty(getEnvironmentVariableKey("GO_SCM_%s_%s", key), value, isSecure);
      }
    }
  }