@Test public void testBeforeRunnerStartButFalseIntegrationEnabledParam() throws Exception { BuildRunnerContext runner = EasyMock.createMock(BuildRunnerContext.class); HashMap<String, String> runnerParameters = Maps.newHashMap(); runnerParameters.put(RunnerParameterKeys.IVY_INTEGRATION, Boolean.FALSE.toString()); EasyMock.expect(runner.getRunnerParameters()).andReturn(runnerParameters); EasyMock.expect(runner.getRunType()).andReturn(RunTypeUtils.ANT_RUNNER); EasyMock.replay(runner); listener.beforeRunnerStart(runner); EasyMock.verify(runner); }
@Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); String runType = runner.getRunType(); Map<String, String> runnerParameters = runner.getRunnerParameters(); if (RunTypeUtils.isAntWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { runner.getBuild().getBuildLogger().warning(skipLogMessage); } return; } File pluginsDirectory = runner.getBuild().getAgentConfiguration().getAgentPluginsDirectory(); File pluginLibDir = new File(pluginsDirectory, ConstantValues.NAME + File.separator + "lib"); try { runner.addSystemProperty("teamcity.ant.classpath", pluginLibDir.getCanonicalPath()); } catch (IOException e) { throw new RuntimeException("Could not get the canonical path of the Build Info dependency directory", e); } StringBuilder builder = new StringBuilder(); if (runnerParameters.containsKey("runnerArgs")) { builder.append(runnerParameters.get("runnerArgs")); } builder.append(" -listener org.jfrog.build.extractor.listener.ArtifactoryBuildListener"); runner.addRunnerParameter("runnerArgs", builder.toString()); runner.addRunnerParameter(RunnerParameterKeys.PUBLISH_BUILD_INFO, Boolean.TRUE.toString()); ArtifactoryClientConfiguration clientConf = ArtifactoryClientConfigurationBuilder.create(runner); try { File tempPropFile = File.createTempFile("buildInfo", "properties"); clientConf.setPropertiesFile(tempPropFile.getCanonicalPath()); clientConf.persistToPropertiesFile(); runner.addSystemProperty(BuildInfoConfigProperties.PROP_PROPS_FILE, tempPropFile.getCanonicalPath()); } catch (IOException ioe) { throw new RuntimeException("Could not write Build Info properties file.", ioe); } } }
IvyBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); String runType = runner.getRunType(); Map<String, String> runnerParameters = runner.getRunnerParameters(); if (RunTypeUtils.isAntWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { runner.getBuild().getBuildLogger().warning(skipLogMessage); } return; } File pluginsDirectory = runner.getBuild().getAgentConfiguration().getAgentPluginsDirectory(); File pluginLibDir = new File(pluginsDirectory, ConstantValues.NAME + File.separator + "lib"); try { runner.addSystemProperty("teamcity.ant.classpath", pluginLibDir.getCanonicalPath()); } catch (IOException e) { throw new RuntimeException("Could not get the canonical path of the Build Info dependency directory", e); } StringBuilder builder = new StringBuilder(); if (runnerParameters.containsKey("runnerArgs")) { builder.append(runnerParameters.get("runnerArgs")); } builder.append(" -listener org.jfrog.build.extractor.listener.ArtifactoryBuildListener"); runner.addRunnerParameter("runnerArgs", builder.toString()); runner.addRunnerParameter(RunnerParameterKeys.PUBLISH_BUILD_INFO, Boolean.TRUE.toString()); ArtifactoryClientConfiguration clientConf = ArtifactoryClientConfigurationBuilder.create(runner); try { File tempPropFile = File.createTempFile("buildInfo", "properties"); clientConf.setPropertiesFile(tempPropFile.getCanonicalPath()); clientConf.persistToPropertiesFile(); runner.addSystemProperty(BuildInfoConfigProperties.PROP_PROPS_FILE, tempPropFile.getCanonicalPath()); } catch (IOException ioe) { throw new RuntimeException("Could not write Build Info properties file.", ioe); } } } }
IvyBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); String runType = runner.getRunType(); Map<String, String> runnerParameters = runner.getRunnerParameters(); if (RunTypeUtils.isAntWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { runner.getBuild().getBuildLogger().warning(skipLogMessage); } return; } File pluginsDirectory = runner.getBuild().getAgentConfiguration().getAgentPluginsDirectory(); File pluginLibDir = new File(pluginsDirectory, ConstantValues.NAME + File.separator + "lib"); try { runner.addSystemProperty("teamcity.ant.classpath", pluginLibDir.getCanonicalPath()); } catch (IOException e) { throw new RuntimeException("Could not get the canonical path of the Build Info dependency directory", e); } StringBuilder builder = new StringBuilder(); if (runnerParameters.containsKey("runnerArgs")) { builder.append(runnerParameters.get("runnerArgs")); } builder.append(" -listener org.jfrog.build.extractor.listener.ArtifactoryBuildListener"); runner.addRunnerParameter("runnerArgs", builder.toString()); runner.addRunnerParameter(RunnerParameterKeys.PUBLISH_BUILD_INFO, Boolean.TRUE.toString()); ArtifactoryClientConfiguration clientConf = ArtifactoryClientConfigurationBuilder.create(runner); try { File tempPropFile = File.createTempFile("buildInfo", "properties"); clientConf.setPropertiesFile(tempPropFile.getCanonicalPath()); clientConf.persistToPropertiesFile(); runner.addSystemProperty(BuildInfoConfigProperties.PROP_PROPS_FILE, tempPropFile.getCanonicalPath()); } catch (IOException ioe) { throw new RuntimeException("Could not write Build Info properties file.", ioe); } } } IvyBuildInfoAgentListener(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher); }
IvyBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); String runType = runner.getRunType(); Map<String, String> runnerParameters = runner.getRunnerParameters(); if (RunTypeUtils.isAntWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { runner.getBuild().getBuildLogger().warning(skipLogMessage); } return; } File pluginsDirectory = runner.getBuild().getAgentConfiguration().getAgentPluginsDirectory(); File pluginLibDir = new File(pluginsDirectory, ConstantValues.NAME + File.separator + "lib"); try { runner.addSystemProperty("teamcity.ant.classpath", pluginLibDir.getCanonicalPath()); } catch (IOException e) { throw new RuntimeException("Could not get the canonical path of the Build Info dependency directory", e); } StringBuilder builder = new StringBuilder(); if (runnerParameters.containsKey("runnerArgs")) { builder.append(runnerParameters.get("runnerArgs")); } builder.append(" -listener org.jfrog.build.extractor.listener.ArtifactoryBuildListener"); runner.addRunnerParameter("runnerArgs", builder.toString()); runner.addRunnerParameter(RunnerParameterKeys.PUBLISH_BUILD_INFO, Boolean.TRUE.toString()); ArtifactoryClientConfiguration clientConf = ArtifactoryClientConfigurationBuilder.create(runner); try { File tempPropFile = File.createTempFile("buildInfo", "properties"); clientConf.setPropertiesFile(tempPropFile.getCanonicalPath()); clientConf.persistToPropertiesFile(); runner.addSystemProperty(BuildInfoConfigProperties.PROP_PROPS_FILE, tempPropFile.getCanonicalPath()); } catch (IOException ioe) { throw new RuntimeException("Could not write Build Info properties file.", ioe); } } } IvyBuildInfoAgentListener(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher); @Override void beforeRunnerStart(@NotNull BuildRunnerContext runner); }
IvyBuildInfoAgentListener extends ArtifactoryAgentLifeCycleAdapter { @Override public void beforeRunnerStart(@NotNull BuildRunnerContext runner) { super.beforeRunnerStart(runner); String runType = runner.getRunType(); Map<String, String> runnerParameters = runner.getRunnerParameters(); if (RunTypeUtils.isAntWithExtractorActivated(runType, runnerParameters)) { String selectedServerUrl = runnerParameters.get(URL); boolean validServerUrl = StringUtils.isNotBlank(selectedServerUrl); if (!validServerUrl) { String skipLogMessage = runnerParameters.get(PROP_SKIP_LOG_MESSAGE); if (StringUtils.isNotBlank(skipLogMessage)) { runner.getBuild().getBuildLogger().warning(skipLogMessage); } return; } File pluginsDirectory = runner.getBuild().getAgentConfiguration().getAgentPluginsDirectory(); File pluginLibDir = new File(pluginsDirectory, ConstantValues.NAME + File.separator + "lib"); try { runner.addSystemProperty("teamcity.ant.classpath", pluginLibDir.getCanonicalPath()); } catch (IOException e) { throw new RuntimeException("Could not get the canonical path of the Build Info dependency directory", e); } StringBuilder builder = new StringBuilder(); if (runnerParameters.containsKey("runnerArgs")) { builder.append(runnerParameters.get("runnerArgs")); } builder.append(" -listener org.jfrog.build.extractor.listener.ArtifactoryBuildListener"); runner.addRunnerParameter("runnerArgs", builder.toString()); runner.addRunnerParameter(RunnerParameterKeys.PUBLISH_BUILD_INFO, Boolean.TRUE.toString()); ArtifactoryClientConfiguration clientConf = ArtifactoryClientConfigurationBuilder.create(runner); try { File tempPropFile = File.createTempFile("buildInfo", "properties"); clientConf.setPropertiesFile(tempPropFile.getCanonicalPath()); clientConf.persistToPropertiesFile(); runner.addSystemProperty(BuildInfoConfigProperties.PROP_PROPS_FILE, tempPropFile.getCanonicalPath()); } catch (IOException ioe) { throw new RuntimeException("Could not write Build Info properties file.", ioe); } } } IvyBuildInfoAgentListener(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher); @Override void beforeRunnerStart(@NotNull BuildRunnerContext runner);  }