Skip to content

Commit

Permalink
[JENKINS-28980] Reproduce
Browse files Browse the repository at this point in the history
  • Loading branch information
olivergondza committed Jun 19, 2015
1 parent a4adf77 commit 7869547
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 15 deletions.
Expand Up @@ -24,6 +24,8 @@
package org.jenkinsci.test.acceptance.plugins.compress_artifacts;

import org.jenkinsci.test.acceptance.po.ArtifactManagement;
import org.jenkinsci.test.acceptance.po.Jenkins;
import org.jenkinsci.test.acceptance.po.JenkinsConfig;
import org.jenkinsci.test.acceptance.po.ArtifactManagement.Factory;
import org.jenkinsci.test.acceptance.po.Describable;

Expand All @@ -33,4 +35,11 @@ public class CompressingArtifactManager extends Factory {
public CompressingArtifactManager(ArtifactManagement management, String relativePath) {
super(management, relativePath);
}

public static void setup(Jenkins jenkins) {
JenkinsConfig config = jenkins.getConfigPage();
config.configure();
config.addArtifactManager(CompressingArtifactManager.class);
config.save();
}
}
@@ -0,0 +1,33 @@
/*
* The MIT License
*
* Copyright (c) 2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;

import org.jenkinsci.test.acceptance.po.PageAreaImpl;

public abstract class BuildParameters extends PageAreaImpl {

protected BuildParameters(TriggerConfig area, String path) {
super(area, path);
}
}
@@ -0,0 +1,37 @@
/*
* The MIT License
*
* Copyright (c) 2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;

import org.jenkinsci.test.acceptance.po.Control;
import org.jenkinsci.test.acceptance.po.Describable;

@Describable("Parameters from properties file")
public class FileBuildParameters extends BuildParameters {
public final Control file = control("propertiesFile");
public final Control failIfMissing = control("failTriggerOnMissing");

public FileBuildParameters(TriggerConfig area, String path) {
super(area, path);
}
}
@@ -1,18 +1,18 @@
package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;

import org.jenkinsci.test.acceptance.po.AbstractStep;
import org.jenkinsci.test.acceptance.po.BuildStep;
import org.jenkinsci.test.acceptance.po.Describable;
import org.jenkinsci.test.acceptance.po.Job;
import org.jenkinsci.test.acceptance.po.PostBuildStep;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
* @author Kohsuke Kawaguchi
*/
@Describable("Trigger/call builds on other projects")
public class ParameterizedTrigger extends AbstractStep implements BuildStep {
@Describable("Trigger parameterized build on other projects")
public class ParameterizedTrigger extends AbstractStep implements PostBuildStep {

public ParameterizedTrigger(Job parent, String path) {
super(parent, path);
Expand Down
@@ -1,7 +1,6 @@
package org.jenkinsci.test.acceptance.plugins.parameterized_trigger;

import org.jenkinsci.test.acceptance.po.Control;
import org.jenkinsci.test.acceptance.po.PageArea;
import org.jenkinsci.test.acceptance.po.PageAreaImpl;

/**
Expand All @@ -14,4 +13,10 @@ public class TriggerConfig extends PageAreaImpl {
public TriggerConfig(ParameterizedTrigger parent, String relativePath) {
super(parent, relativePath);
}

public <Ret extends BuildParameters> Ret addParameter(Class<Ret> type) {
control("hetero-list-add[configs]").selectDropdownMenu(type);
String path = last(by.xpath("//div[@name='configs']")).getAttribute("path");
return newInstance(type, this, path);
}
}
14 changes: 3 additions & 11 deletions src/test/java/plugins/CompressArtifactsPluginTest.java
Expand Up @@ -38,7 +38,6 @@
import org.jenkinsci.test.acceptance.po.ArtifactArchiver;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.FreeStyleJob;
import org.jenkinsci.test.acceptance.po.JenkinsConfig;
import org.jenkinsci.test.acceptance.po.ShellBuildStep;
import org.junit.Test;

Expand All @@ -50,7 +49,7 @@ public class CompressArtifactsPluginTest extends AbstractJUnitTest {
@Test
@WithPlugins("compress-artifacts")
public void archive_compressed_artifacts() {
configureArtifactCompression();
CompressingArtifactManager.setup(jenkins);
Build build = generateArtifact();

assertThat(build.getArtifacts(), hasSize(1));
Expand All @@ -69,7 +68,7 @@ public void access_uncompressed_artifact_after_plugin_was_installed() {
build.getArtifact(ARTIFACT_NAME).shouldHaveContent("content");
assertThat(build, not(hasCompressedArtifacts()));

configureArtifactCompression();
CompressingArtifactManager.setup(jenkins);

// Works after configuration
assertThat(build.getArtifacts(), hasSize(1));
Expand All @@ -80,7 +79,7 @@ public void access_uncompressed_artifact_after_plugin_was_installed() {
@Test @Issue("JENKINS-27042")
@WithPlugins("compress-artifacts")
public void archiveLargerThan4GInTotal() throws Exception {
configureArtifactCompression();
CompressingArtifactManager.setup(jenkins);

FreeStyleJob job = jenkins.jobs.create();
job.configure();
Expand Down Expand Up @@ -110,13 +109,6 @@ private void installCompressPlugin() {
if (restart) jenkins.restart();
}

private void configureArtifactCompression() {
JenkinsConfig config = jenkins.getConfigPage();
config.configure();
config.addArtifactManager(CompressingArtifactManager.class);
config.save();
}

private Build generateArtifact() {
FreeStyleJob job = jenkins.jobs.create();
job.addBuildStep(ShellBuildStep.class).command("echo 'content' > " + ARTIFACT_NAME);
Expand Down
70 changes: 70 additions & 0 deletions src/test/java/plugins/ParameterizedTriggerTest.java
@@ -0,0 +1,70 @@
/*
* The MIT License
*
* Copyright (c) 2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package plugins;

import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
import org.jenkinsci.test.acceptance.plugins.compress_artifacts.CompressingArtifactManager;
import org.jenkinsci.test.acceptance.plugins.parameterized_trigger.FileBuildParameters;
import org.jenkinsci.test.acceptance.plugins.parameterized_trigger.ParameterizedTrigger;
import org.jenkinsci.test.acceptance.plugins.parameterized_trigger.TriggerConfig;
import org.jenkinsci.test.acceptance.po.ArtifactArchiver;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.FreeStyleJob;
import org.jenkinsci.test.acceptance.po.StringParameter;
import org.junit.Test;

@WithPlugins("parameterized-trigger")
public class ParameterizedTriggerTest extends AbstractJUnitTest {

@Test @WithPlugins("compress-artifacts")
public void triggerWithNonStandardArchiver() {
CompressingArtifactManager.setup(jenkins);

FreeStyleJob target = jenkins.jobs.create();
target.configure();
target.addParameter(StringParameter.class).setName("PARAM");
target.addShellStep("test 'value' = $PARAM");
target.save();

FreeStyleJob trigger = jenkins.jobs.create();
trigger.configure();
trigger.addShellStep("echo 'PARAM=value' > my.properties");

ArtifactArchiver archiver = trigger.addPublisher(ArtifactArchiver.class);
archiver.includes("my.properties");

ParameterizedTrigger step = trigger.addPublisher(ParameterizedTrigger.class);
TriggerConfig config = step.getTriggerConfig(0);
config.projects.set(target.name);
FileBuildParameters params = config.addParameter(FileBuildParameters.class);
params.file.set("my.properties");
params.failIfMissing.check();
trigger.save();

trigger.startBuild().shouldSucceed();
Build downstream = target.build(1);
downstream.shouldSucceed();
}
}

0 comments on commit 7869547

Please sign in to comment.