本文整理汇总了Java中com.thoughtworks.go.plugin.api.task.JobConsoleLogger类的典型用法代码示例。如果您正苦于以下问题:Java JobConsoleLogger类的具体用法?Java JobConsoleLogger怎么用?Java JobConsoleLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JobConsoleLogger类属于com.thoughtworks.go.plugin.api.task包,在下文中一共展示了JobConsoleLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ExecutionResult execute(ExecutionContext context, ExecutionConfiguration config, JobConsoleLogger console) {
try {
final ProcessBuilder gradle = buildGradleProcess(config, context);
int result = execute(gradle, console);
if (!isSuccess(result)) {
return ExecutionResult.failure(FAILURE);
}
return ExecutionResult.success(SUCCESS);
} catch (Exception e) {
logger.error("Build failed with error", e);
console.printLine(e.getMessage());
console.printLine(ExceptionUtils.getStackTrace(e));
return ExecutionResult.failure(FAILURE, e);
}
}
示例2: shouldBuildGradleProjectUsingWrapper
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
@Test
public void shouldBuildGradleProjectUsingWrapper() throws Exception {
// given
final ExecutionContext executionContext = createExecutionContext();
final ExecutionConfiguration executionConfiguration =
createExecutionConfig(singletonMap(USE_WRAPPER.getName(), TRUE.toString()));
final JobConsoleLogger jobConsoleLogger = createConsoleLogger();
// when
final ExecutionResult result = instance.execute(executionContext, executionConfiguration, jobConsoleLogger);
// then
assertNotNull(result);
assertTrue(result.isSuccess());
}
示例3: shouldBuildGradleProjectUsingWrapperAndSetExecutablePermission
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
@Test
public void shouldBuildGradleProjectUsingWrapperAndSetExecutablePermission() throws Exception {
// given
final ExecutionContext executionContext = createExecutionContext();
final Map<String, String> settings = new HashMap<>();
settings.put(USE_WRAPPER.getName(), TRUE.toString());
settings.put(MAKE_WRAPPER_EXECUTABLE.getName(), TRUE.toString());
final ExecutionConfiguration executionConfiguration = createExecutionConfig(settings);
final JobConsoleLogger jobConsoleLogger = createConsoleLogger();
// when
final ExecutionResult result = instance.execute(executionContext, executionConfiguration, jobConsoleLogger);
// then
assertNotNull(result);
assertTrue(result.isSuccess());
}
示例4: shouldBuildGradleProjectUsingWrapperInWindowsRelativeDirectory
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
@Test
public void shouldBuildGradleProjectUsingWrapperInWindowsRelativeDirectory() throws Exception {
// given
final ExecutionContext executionContext = createExecutionContext("src\\test\\resources\\gradle");
final Map<String, String> settings = new HashMap<>();
settings.put(USE_WRAPPER.getName(), TRUE.toString());
final ExecutionConfiguration executionConfiguration = createExecutionConfig(settings);
final JobConsoleLogger jobConsoleLogger = createConsoleLogger();
// when
final ExecutionResult result = instance.execute(executionContext, executionConfiguration, jobConsoleLogger);
// then
assertNotNull(result);
assertTrue(result.isSuccess());
}
示例5: shouldSuccess
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
/**
* Tests whether the health check succeeds.
*/
@Test
public void shouldSuccess() {
// given
final ExecutionContext context = new ExecutionContext(new HashMap());
final ExecutionConfiguration configuration = configuration(url("/health"), "status", "UP", 15, 30);
final JobConsoleLogger logger = mock(JobConsoleLogger.class);
// when
ExecutionResult result = instance.execute(context, configuration, logger);
// then
assertNotNull(result);
assertTrue(result.isSuccess());
}
示例6: shouldSuccessWithDotNotation
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
/**
* Tests whether the health check succeeds.
*/
@Test
public void shouldSuccessWithDotNotation() {
// given
final ExecutionContext context = new ExecutionContext(new HashMap());
final ExecutionConfiguration configuration = configuration(url("/health"), "service.status", "UP", 15, 30);
final JobConsoleLogger logger = mock(JobConsoleLogger.class);
// when
ExecutionResult result = instance.execute(context, configuration, logger);
// then
assertNotNull(result);
assertTrue(result.isSuccess());
}
示例7: shouldTimeoutStatus
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
/**
* Tests the timeout and failure of the task on incorrect application status.
*/
@Test
public void shouldTimeoutStatus() {
// given
final ExecutionContext context = new ExecutionContext(new HashMap());
final ExecutionConfiguration configuration = configuration(url("/health"), "status", "OK", 15, 30);
final JobConsoleLogger logger = mock(JobConsoleLogger.class);
// when
ExecutionResult result = instance.execute(context, configuration, logger);
// then
assertNotNull(result);
assertFalse(result.isSuccess());
}
示例8: shouldTimeoutConnection
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
/**
* Tests the timeout and failure of the task on connection error.
*/
@Test
public void shouldTimeoutConnection() {
// given
final ExecutionContext context = new ExecutionContext(new HashMap());
final ExecutionConfiguration configuration = configuration(url("/"), "status", "UP", 15, 30);
final JobConsoleLogger logger = mock(JobConsoleLogger.class);
// when
ExecutionResult result = instance.execute(context, configuration, logger);
// then
assertNotNull(result);
assertFalse(result.isSuccess());
}
示例9: Init
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
@BeforeClass
public static void Init() throws Exception {
CheckMkStub.init();
config = Mockito.mock(Map.class);
consoleLogger = Mockito.mock(JobConsoleLogger.class);
context = Mockito.mock(Context.class);
Map serverMock = Mockito.mock(Map.class);
Mockito.when(serverMock.get("value")).thenReturn(CheckMkStub.server);
Mockito.when(config.get(CheckMkTask.CHECK_MK_SERVER)).thenReturn(serverMock);
Map hostnameMock = Mockito.mock(Map.class);
Mockito.when(hostnameMock.get("value")).thenReturn(CheckMkStub.hostName);
Mockito.when(config.get(CheckMkTask.HOSTNAME)).thenReturn(hostnameMock);
Map userNameMock = Mockito.mock(Map.class);
Mockito.when(userNameMock.get("value")).thenReturn(CheckMkStub.userName);
Mockito.when(config.get(CheckMkTask.USERNAME)).thenReturn(userNameMock);
Map passwordMock = Mockito.mock(Map.class);
Mockito.when(passwordMock.get("value")).thenReturn(CheckMkStub.password);
Mockito.when(config.get(CheckMkTask.PASSWORD)).thenReturn(passwordMock);
}
示例10: DockerMachineListCommand
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
public DockerMachineListCommand(JobConsoleLogger console, ConfigVars configVars, boolean quiet, String filter, String format) {
super(console, true);
add("docker-machine");
add("ls");
if (quiet) {
add("--quiet");
}
if (filter != null) {
add("--filter");
add(filter);
}
if (format != null) {
add("--format");
add(format);
}
}
示例11: DockerComposeCommand
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
public DockerComposeCommand(JobConsoleLogger console, ConfigVars configVars) throws FileNotFoundException {
super(console);
// 1. just copy from the current environment
addEnv(configVars.environmentVars());
// 2. variables stated/defined explicitly
addEnv(splitKeyValues(configVars.getValue(DockerComposeTask.ENV_VARS)));
// 3. variables defined by the configuration settings
addEnvFromConfig(configVars, DockerComposeTask.COMPOSE_FILE);
// 4. variables based on the docker-machine environment settings
addEnv(getDockerMachineEnv(configVars.getValue(DockerComposeTask.VMNAME)));
add("docker-compose");
}
示例12: DockerContainerIdCommand
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
public DockerContainerIdCommand(JobConsoleLogger console, ConfigVars configVars) {
super(console, configVars);
disableConsoleOutput();
try {
add("docker");
add("ps");
add("-q");
run();
ProcessOutput output = getProcessOutput();
if (output.isZeroReturnCode() && (output.getStdOut().size() > 0)) {
command.clear();
add("docker");
add("inspect");
for (String s : output.getStdOut()) {
add(s);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: execute
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ExecutionResult execute(ExecutionContext context, ExecutionConfiguration config, JobConsoleLogger console) {
try {
final ProcessBuilder sbt = buildSbtProcess(context, config);
int result = execute(sbt, console);
if (!isSuccess(result)) {
return ExecutionResult.failure(FAILURE);
}
return ExecutionResult.success(SUCCESS);
} catch (Exception e) {
logger.error("Build failed with error", e);
console.printLine(e.getMessage());
console.printLine(ExceptionUtils.getStackTrace(e));
return ExecutionResult.failure(FAILURE, e);
}
}
示例14: shouldBuildGradleProject
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
@Test
public void shouldBuildGradleProject() throws Exception {
// given
final ExecutionContext executionContext = createExecutionContext();
final ExecutionConfiguration executionConfiguration = createExecutionConfig(Collections.<String, String>emptyMap());
final JobConsoleLogger jobConsoleLogger = createConsoleLogger();
// when
final ExecutionResult result = instance.execute(executionContext, executionConfiguration, jobConsoleLogger);
// then
assertNotNull(result);
assertTrue(result.isSuccess());
}
示例15: execute
import com.thoughtworks.go.plugin.api.task.JobConsoleLogger; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ExecutionResult execute(ExecutionContext context, ExecutionConfiguration config, JobConsoleLogger console) {
try {
final String healthCheckUrl = getProperty(config, HealthCheckTaskConfig.URL);
final String attribute = getProperty(config, HealthCheckTaskConfig.ATTRIBUTE);
final String status = getProperty(config, HealthCheckTaskConfig.STATUS);
final int timeout = getIntProperty(config, HealthCheckTaskConfig.TIMEOUT, 60);
final int retryDelay = getIntProperty(config, HealthCheckTaskConfig.DELAY, 15);
final boolean success = RxNetty.createHttpGet(healthCheckUrl)
.flatMap(parseJsonElement())
.map(mapStatusAttribute(attribute))
.map(mapAttributeValue())
.map(matchStatus(status))
.filter(filterStatuses())
.switchIfEmpty(Observable.<Boolean>error(null))
.retryWhen(retryPolicy(retryDelay, timeout))
.timeout(timeout, TimeUnit.SECONDS)
.toBlocking()
.firstOrDefault(false);
if (!success) {
return ExecutionResult.failure("Health check failed");
}
return ExecutionResult.success("Health check succeeded");
} catch (Exception e) {
logger.error("Unexpected error occurred when executing task", e);
return ExecutionResult.failure("Health check failed", e);
}
}