@Test public void testBeforeRunnerStartButNotGradleRunner() throws Exception { BuildRunnerContext runner = EasyMock.createMock(BuildRunnerContext.class); EasyMock.expect(runner.getRunnerParameters()).andReturn(Maps.<String, String>newHashMap()); EasyMock.expect(runner.getRunType()).andReturn("notgradle"); EasyMock.replay(runner); listener.beforeRunnerStart(runner); EasyMock.verify(runner); }
@Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); Map<String, String> runnerParameters = runner.getRunnerParameters(); String runType = runner.getRunType(); if (RunTypeUtils.isGradleWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); AgentRunningBuild build = runner.getBuild(); BuildProgressLogger logger = build.getBuildLogger(); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { logger.warning(skipLogMessage); } } else { if (Boolean.valueOf(runnerParameters.get(RunnerParameterKeys.ENABLE_RELEASE_MANAGEMENT))) { File workingDirectory = runner.getWorkingDirectory(); File gradleProperties = new File(workingDirectory, ConstantValues.GRADLE_PROPERTIES_FILE_NAME); if (!gradleProperties.exists()) { String errorMessage = "Unable to find the gradle release management properties file at '" + gradleProperties.getAbsolutePath() + "'."; logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(new FileNotFoundException(errorMessage)); return; } File gradlePropertiesPacked; try { gradlePropertiesPacked = ArchiveUtil.packFile(gradleProperties); } catch (IOException e) { String errorMessage = "Unable to publish the '" + ConstantValues.GRADLE_PROPERTIES_FILE_NAME + "' file to the server: " + e.getMessage(); logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(e); return; } watcher.addNewArtifactsPath(gradlePropertiesPacked.getAbsolutePath() + "=>.teamcity"); } addBuildInfoTaskAndInitScript(runner); } } }
GradleBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); Map<String, String> runnerParameters = runner.getRunnerParameters(); String runType = runner.getRunType(); if (RunTypeUtils.isGradleWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); AgentRunningBuild build = runner.getBuild(); BuildProgressLogger logger = build.getBuildLogger(); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { logger.warning(skipLogMessage); } } else { if (Boolean.valueOf(runnerParameters.get(RunnerParameterKeys.ENABLE_RELEASE_MANAGEMENT))) { File workingDirectory = runner.getWorkingDirectory(); File gradleProperties = new File(workingDirectory, ConstantValues.GRADLE_PROPERTIES_FILE_NAME); if (!gradleProperties.exists()) { String errorMessage = "Unable to find the gradle release management properties file at '" + gradleProperties.getAbsolutePath() + "'."; logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(new FileNotFoundException(errorMessage)); return; } File gradlePropertiesPacked; try { gradlePropertiesPacked = ArchiveUtil.packFile(gradleProperties); } catch (IOException e) { String errorMessage = "Unable to publish the '" + ConstantValues.GRADLE_PROPERTIES_FILE_NAME + "' file to the server: " + e.getMessage(); logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(e); return; } watcher.addNewArtifactsPath(gradlePropertiesPacked.getAbsolutePath() + "=>.teamcity"); } addBuildInfoTaskAndInitScript(runner); } } } }
GradleBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); Map<String, String> runnerParameters = runner.getRunnerParameters(); String runType = runner.getRunType(); if (RunTypeUtils.isGradleWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); AgentRunningBuild build = runner.getBuild(); BuildProgressLogger logger = build.getBuildLogger(); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { logger.warning(skipLogMessage); } } else { if (Boolean.valueOf(runnerParameters.get(RunnerParameterKeys.ENABLE_RELEASE_MANAGEMENT))) { File workingDirectory = runner.getWorkingDirectory(); File gradleProperties = new File(workingDirectory, ConstantValues.GRADLE_PROPERTIES_FILE_NAME); if (!gradleProperties.exists()) { String errorMessage = "Unable to find the gradle release management properties file at '" + gradleProperties.getAbsolutePath() + "'."; logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(new FileNotFoundException(errorMessage)); return; } File gradlePropertiesPacked; try { gradlePropertiesPacked = ArchiveUtil.packFile(gradleProperties); } catch (IOException e) { String errorMessage = "Unable to publish the '" + ConstantValues.GRADLE_PROPERTIES_FILE_NAME + "' file to the server: " + e.getMessage(); logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(e); return; } watcher.addNewArtifactsPath(gradlePropertiesPacked.getAbsolutePath() + "=>.teamcity"); } addBuildInfoTaskAndInitScript(runner); } } } GradleBuildInfoAgentListener(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher,
                                        @NotNull ArtifactsWatcher watcher); }
GradleBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); Map<String, String> runnerParameters = runner.getRunnerParameters(); String runType = runner.getRunType(); if (RunTypeUtils.isGradleWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); AgentRunningBuild build = runner.getBuild(); BuildProgressLogger logger = build.getBuildLogger(); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { logger.warning(skipLogMessage); } } else { if (Boolean.valueOf(runnerParameters.get(RunnerParameterKeys.ENABLE_RELEASE_MANAGEMENT))) { File workingDirectory = runner.getWorkingDirectory(); File gradleProperties = new File(workingDirectory, ConstantValues.GRADLE_PROPERTIES_FILE_NAME); if (!gradleProperties.exists()) { String errorMessage = "Unable to find the gradle release management properties file at '" + gradleProperties.getAbsolutePath() + "'."; logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(new FileNotFoundException(errorMessage)); return; } File gradlePropertiesPacked; try { gradlePropertiesPacked = ArchiveUtil.packFile(gradleProperties); } catch (IOException e) { String errorMessage = "Unable to publish the '" + ConstantValues.GRADLE_PROPERTIES_FILE_NAME + "' file to the server: " + e.getMessage(); logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(e); return; } watcher.addNewArtifactsPath(gradlePropertiesPacked.getAbsolutePath() + "=>.teamcity"); } addBuildInfoTaskAndInitScript(runner); } } } GradleBuildInfoAgentListener(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher,
                                        @NotNull ArtifactsWatcher watcher); @Override void beforeRunnerStart(@NotNull BuildRunnerContext runner); }
GradleBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); Map<String, String> runnerParameters = runner.getRunnerParameters(); String runType = runner.getRunType(); if (RunTypeUtils.isGradleWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); AgentRunningBuild build = runner.getBuild(); BuildProgressLogger logger = build.getBuildLogger(); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { logger.warning(skipLogMessage); } } else { if (Boolean.valueOf(runnerParameters.get(RunnerParameterKeys.ENABLE_RELEASE_MANAGEMENT))) { File workingDirectory = runner.getWorkingDirectory(); File gradleProperties = new File(workingDirectory, ConstantValues.GRADLE_PROPERTIES_FILE_NAME); if (!gradleProperties.exists()) { String errorMessage = "Unable to find the gradle release management properties file at '" + gradleProperties.getAbsolutePath() + "'."; logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(new FileNotFoundException(errorMessage)); return; } File gradlePropertiesPacked; try { gradlePropertiesPacked = ArchiveUtil.packFile(gradleProperties); } catch (IOException e) { String errorMessage = "Unable to publish the '" + ConstantValues.GRADLE_PROPERTIES_FILE_NAME + "' file to the server: " + e.getMessage(); logger.error(errorMessage); logger.buildFailureDescription(errorMessage); logger.exception(e); return; } watcher.addNewArtifactsPath(gradlePropertiesPacked.getAbsolutePath() + "=>.teamcity"); } addBuildInfoTaskAndInitScript(runner); } } } GradleBuildInfoAgentListener(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher,
                                        @NotNull ArtifactsWatcher watcher); @Override void beforeRunnerStart(@NotNull BuildRunnerContext runner);  }