Search in sources :

Example 11 with Property

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());
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property)

Example 12 with Property

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;
}
Also used : XPathExpressionException(javax.xml.xpath.XPathExpressionException) File(java.io.File) Property(com.thoughtworks.go.domain.Property) XPathExpressionException(javax.xml.xpath.XPathExpressionException)

Example 13 with Property

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));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property)

Aggregations

Property (com.thoughtworks.go.domain.Property)13 Properties (com.thoughtworks.go.domain.Properties)6 Test (org.junit.Test)5 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)3 Csv (com.thoughtworks.go.util.Csv)3 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 File (java.io.File)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)2 PropertyDao (com.thoughtworks.go.server.dao.PropertyDao)1 CsvRow (com.thoughtworks.go.util.CsvRow)1 ArrayList (java.util.ArrayList)1