use of com.thoughtworks.go.domain.Property in project gocd by gocd.
the class PropertiesService method listPropertiesForJob.
public RestfulAction listPropertiesForJob(JobIdentifier jobIdentifier, String type, String propertyKey) {
Properties properties;
Long buildId = jobIdentifier.getBuildId();
if (propertyKey != null) {
String value = propertyDao.value(buildId, propertyKey);
if (value == null) {
return PropertyAction.propertyNotFound(propertyKey);
}
properties = new Properties(new Property(propertyKey, value));
} else {
properties = propertyDao.list(jobIdentifier.getBuildId());
}
return listPropertiesAs(type, properties, jobIdentifier.getBuildName());
}
use of com.thoughtworks.go.domain.Property in project gocd by gocd.
the class GeneratePropertyCommandExecutor method execute.
@Override
public boolean execute(BuildCommand command, BuildSession buildSession) {
String propertyName = command.getStringArg("name");
File file = buildSession.resolveRelativeDir(command.getWorkingDirectory(), command.getStringArg("src"));
String xpath = command.getStringArg("xpath");
String indent = " ";
if (!file.exists()) {
buildSession.println(format("%sFailed to create property %s. File %s does not exist.", indent, propertyName, file.getAbsolutePath()));
return true;
}
try {
if (!XpathUtils.nodeExists(file, xpath)) {
buildSession.println(format("%sFailed to create property %s. Nothing matched xpath \"%s\" in the file: %s.", indent, propertyName, xpath, file.getAbsolutePath()));
} else {
String value = XpathUtils.evaluate(file, xpath);
buildSession.getPublisher().setProperty(new Property(propertyName, value));
buildSession.println(format("%sProperty %s = %s created." + "\n", indent, propertyName, value));
}
} catch (Exception e) {
String error = (e instanceof XPathExpressionException) ? (format("Illegal xpath: \"%s\"", xpath)) : ExceptionUtils.messageOf(e);
String message = format("%sFailed to create property %s. %s", indent, propertyName, error);
buildSession.getPublisher().reportErrorMessage(message, e);
}
return true;
}
use of com.thoughtworks.go.domain.Property in project gocd by gocd.
the class PropertySqlMapDao method addToHistory.
private static void addToHistory(LinkedHashMap<String, Properties> propHistory, Map<String, Object> flatMap) {
String id = String.valueOf(flatMap.get("pipelineid"));
String key = (String) flatMap.get("key");
String value = (String) flatMap.get("value");
if (!propHistory.containsKey(id)) {
propHistory.put(id, new Properties());
}
propHistory.get(id).add(new Property(key, value));
}
Aggregations