Java Code Examples for jetbrains.buildServer.serverSide.TeamCityProperties#getBoolean()

The following examples show how to use jetbrains.buildServer.serverSide.TeamCityProperties#getBoolean() . 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: S3Util.java    From teamcity-s3-artifact-storage-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
public static Map<String, String> validateParameters(@NotNull final Map<String, String> params, final boolean acceptReferences) {
  final Map<String, String> commonErrors = AWSCommonParams.validate(params, acceptReferences);
  if (!commonErrors.isEmpty()) {
    return commonErrors;
  }
  final Map<String, String> invalids = new HashMap<>();
  if (StringUtil.isEmptyOrSpaces(getBucketName(params))) {
    invalids.put(beanPropertyNameForBucketName(), "S3 bucket name must not be empty");
  }
  final String pathPrefix = params.getOrDefault(S3_PATH_PREFIX_SETTING, "");
  if (TeamCityProperties.getBoolean("teamcity.internal.storage.s3.bucket.prefix.enable") && !StringUtil.isEmptyOrSpaces(pathPrefix)) {
    if (pathPrefix.length() > OUT_MAX_PREFIX_LENGTH) {
      invalids.put(S3_PATH_PREFIX_SETTING, "Should be less than " + OUT_MAX_PREFIX_LENGTH + " characters");
    }
    if (!OUR_OBJECT_KEY_PATTERN.matcher(pathPrefix).matches()) {
      invalids.put(S3_PATH_PREFIX_SETTING, "Should match the regexp [" + OUR_OBJECT_KEY_PATTERN.pattern() + "]");
    }
  }
  return invalids;
}
 
Example 2
Source File: S3PreSignedUrlProviderImpl.java    From teamcity-s3-artifact-storage-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
public String getPreSignedUrl(@NotNull HttpMethod httpMethod, @NotNull String bucketName, @NotNull String objectKey, @NotNull Map<String, String> params) throws IOException {
  try {
    final Callable<String> resolver = getUrlResolver(httpMethod, bucketName, objectKey, params);
    if (httpMethod == HttpMethod.GET) {
      return TeamCityProperties.getBoolean(TEAMCITY_S3_PRESIGNURL_GET_CACHE_ENABLED)
        ? myGetLinksCache.get(getCacheIdentity(params, objectKey, bucketName), resolver)
        : resolver.call();
    } else {
      return resolver.call();
    }
  } catch (Exception e) {
    final Throwable cause = e.getCause();
    final AWSException awsException = cause != null ? new AWSException(cause) : new AWSException(e);
    final String details = awsException.getDetails();
    if (StringUtil.isNotEmpty(details)) {
      final String message = awsException.getMessage() + details;
      LOG.warn(message);
    }
    throw new IOException(String.format(
      "Failed to create pre-signed URL to %s artifact '%s' in bucket '%s': %s",
      httpMethod.name().toLowerCase(), objectKey, bucketName, awsException.getMessage()
    ), awsException);
  }
}
 
Example 3
Source File: SmbDeployerRunner.java    From teamcity-deployer-plugin with Apache License 2.0 5 votes vote down vote up
private boolean shouldEnforceSMBv1(@NotNull final BuildRunnerContext context) {
  boolean shouldEnforceOnBuild =
          StringUtil.isTrue(context.getBuild().getSharedConfigParameters().get(SMBRunnerConstants.SHOULD_ENFORCE_SMB1));
  if (shouldEnforceOnBuild) {
    return true;
  }

  return TeamCityProperties.getBoolean(SMBRunnerConstants.SHOULD_ENFORCE_SMB1);
}
 
Example 4
Source File: VmwareCloudImage.java    From teamcity-vmware-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public synchronized CanStartNewInstanceResult canStartNewInstanceWithDetails() {
  if (getErrorInfo() != null){
    LOG.debug("Can't start new instance, if image is erroneous");
    return CanStartNewInstanceResult.no("Image is erroneous.");
  }

  final String sourceId = myImageDetails.getSourceId();
  if (myImageDetails.getBehaviour().isUseOriginal()) {
    final VmwareCloudInstance myInstance = findInstanceById(sourceId);
    if (myInstance == null) {
      return CanStartNewInstanceResult.no("Can't find original instance by id " + sourceId);
    }
    if (myInstance.getStatus() == InstanceStatus.STOPPED) {
      return CanStartNewInstanceResult.yes();
    }
    return CanStartNewInstanceResult.no("Original instance with id " + sourceId + " is not being stopped");
  }

  final boolean countStoppedVmsInLimit = TeamCityProperties.getBoolean(VmwareConstants.CONSIDER_STOPPED_VMS_LIMIT)
                                         && myImageDetails.getBehaviour().isDeleteAfterStop();

  final List<String> consideredInstances = new ArrayList<String>();
  for (VmwareCloudInstance instance : getInstances()) {
    if (instance.getStatus() != InstanceStatus.STOPPED || countStoppedVmsInLimit)
      consideredInstances.add(instance.getInstanceId());
  }
  final boolean canStartMore =  consideredInstances.size() < myImageDetails.getMaxInstances();
  final String message = String.format("[%s] Instances count: %d %s, can start more: %s", sourceId,
                                       consideredInstances.size(), Arrays.toString(consideredInstances.toArray()), String.valueOf(canStartMore));
  LOG.debug(message);
  return canStartMore ? CanStartNewInstanceResult.yes() : CanStartNewInstanceResult.no("Image instance limit exceeded");
}