Skip to content

Commit

Permalink
Merge pull request #1 from cpoenisch/JENKINS-31999
Browse files Browse the repository at this point in the history
[JENKINS-31999] added Pipeline support
  • Loading branch information
cpoenisch committed May 27, 2016
2 parents 0d7918d + e3db05f commit 0cd8a44
Show file tree
Hide file tree
Showing 93 changed files with 3,768 additions and 1,765 deletions.
119 changes: 75 additions & 44 deletions pom.xml
Expand Up @@ -79,11 +79,12 @@

<properties>
<!-- Jenkins base -->
<jenkins.version>1.565.3</jenkins.version>
<jenkins-test-harness.version>1.565.3</jenkins-test-harness.version>
<jenkins.version>1.580.1</jenkins.version>
<jenkins-test-harness.version>1.580.1</jenkins-test-harness.version>

<!-- Jenkins plugins -->
<matrix-project.version>1.4</matrix-project.version>
<junit.version>1.3</junit.version>
<job-dsl.version>1.37</job-dsl.version>

<!-- Static code analysis -->
Expand All @@ -93,6 +94,7 @@
<!-- Test scope -->
<equalsverifier.version>1.7.8</equalsverifier.version>
<mockito-core.version>1.10.19</mockito-core.version>
<workflow.version>1.4.2</workflow.version>
<concurrency>2</concurrency>

<!-- JACOB -->
Expand Down Expand Up @@ -152,6 +154,12 @@
<artifactId>matrix-project</artifactId>
<version>${matrix-project.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>job-dsl</artifactId>
Expand All @@ -176,6 +184,25 @@
<version>${equalsverifier.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -185,15 +212,33 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<!-- Includes system tests ending with ST -->
<include>**/*Test.java</include>
<include>**/*ST.java</include>
</includes>
<excludes>
<exclude>InjectedTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<includes>
<include>**/*ST.java</include>
<include>InjectedTest.java</include>
</includes>
<reuseForks>true</reuseForks>
<forkCount>${concurrency}</forkCount>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down Expand Up @@ -262,37 +307,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.3,)
</versionRange>
<goals>
<goal>
copy-dependencies
</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand All @@ -314,6 +328,29 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.3,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand All @@ -326,15 +363,9 @@
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-javadoc-plugin
</artifactId>
<versionRange>
[2.10.1,)
</versionRange>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<versionRange>[2.10.1,)</versionRange>
<goals>
<goal>javadoc</goal>
</goals>
Expand Down
Expand Up @@ -58,7 +58,7 @@ public class ETPlugin extends Plugin {
/**
* Defines the TEST-GUIDE version that the provided ATX configuration is based on.
*/
public static final ToolVersion ATX_VERSION = new ToolVersion(1, 29, 0, 0);
public static final ToolVersion ATX_VERSION = new ToolVersion(1, 30, 0, 0);

/**
* Helper class to easily compare tool versions defined by major, minor, micro and qualifier version. Mainly used to
Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015 TraceTronic GmbH
* Copyright (c) 2015-2016 TraceTronic GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -29,49 +29,51 @@
*/
package de.tracetronic.jenkins.plugins.ecutest;

import hudson.Util;
import hudson.PluginWrapper;

import java.io.IOException;

import org.jvnet.hudson.test.TestPluginManager;

/**
* Cleanup the temporary directory created by {@link org.jvnet.hudson.test.TestPluginManager}.
* <p>
* Call {@link #registerCleanup()} at least once from anywhere.
* Exception thrown if an error occurs while performing plugin-specific operations.
*
* @author Christian Pönisch <christian.poenisch@tracetronic.de>
*/
public class TestPluginManagerCleanUp {
public class ETPluginException extends Exception {

private static final long serialVersionUID = 1L;

private static Thread deleteThread = null;
/**
* Instantiates a new {@link ETPluginException}.
*
* @param cause
* the cause of the {@link Exception}
*/
public ETPluginException(final Throwable cause) {
super(cause);
}

/**
* Instantiates a new {@link ETPluginException}.
*
* @param message
* the message to attach to the {@link Exception}
* @param cause
* the cause of the {@link Exception}
*/
public ETPluginException(final String message, final Throwable cause) {
super(message, cause);
}

public static synchronized void registerCleanup() {
if (deleteThread != null) {
return;
}
deleteThread = new Thread("HOTFIX: cleanup " + TestPluginManager.INSTANCE.rootDir) {
/**
* Instantiates a new {@link ETPluginException}.
*
* @param message
* the message to attach to the {@link Exception}
*/
public ETPluginException(final String message) {
super(message);
}

@Override
public void run() {
if (TestPluginManager.INSTANCE != null && TestPluginManager.INSTANCE.rootDir != null
&& TestPluginManager.INSTANCE.rootDir.exists()) {
// Work as PluginManager#stop
for (final PluginWrapper p : TestPluginManager.INSTANCE.getPlugins()) {
p.stop();
p.releaseClassLoader();
}
TestPluginManager.INSTANCE.getPlugins().clear();
System.gc();
try {
Util.deleteRecursive(TestPluginManager.INSTANCE.rootDir);
} catch (final IOException x) {
x.printStackTrace();
}
}
}
};
Runtime.getRuntime().addShutdownHook(deleteThread);
/**
* Instantiates a new {@link ETPluginException}.
*/
public ETPluginException() {
super();
}
}
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015 TraceTronic GmbH
* Copyright (c) 2015-2016 TraceTronic GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -31,11 +31,10 @@

import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.model.InvisibleAction;
import hudson.model.ParameterValue;
import hudson.model.TaskListener;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.model.StringParameterValue;
import hudson.model.listeners.RunListener;

Expand All @@ -59,20 +58,20 @@ public class TestEnvActionView extends InvisibleAction {

private static final Logger LOGGER = Logger.getLogger(TestEnvActionView.class.getName());

private final AbstractBuild<?, ?> build;
private final Run<?, ?> build;
private final transient TaskListener listener;

/**
* Instantiates a new {@link TestEnvActionView}.
*
* @param build
* @param run
* the build
* @param listener
* the listener
*/
public TestEnvActionView(final AbstractBuild<?, ?> build, final TaskListener listener) {
public TestEnvActionView(final Run<?, ?> run, final TaskListener listener) {
super();
this.build = build;
build = run;
this.listener = listener;
}

Expand All @@ -90,9 +89,9 @@ public Set<ParameterValue> getEnvVariables() {
try {
final EnvVars envVars = build.getEnvironment(listener);
String buildWs = "";
final FilePath buildWsPath = build.getWorkspace();
final String buildWsPath = envVars.get("WORKSPACE");
if (buildWsPath != null) {
buildWs = buildWsPath.getRemote() + File.separator;
buildWs = buildWsPath + File.separator;
}

for (int i = 0; i < testBuilderSize; i++) {
Expand All @@ -116,10 +115,10 @@ public Set<ParameterValue> getEnvVariables() {
* Listener notifying the build on completion and adding this {@link TestEnvActionView} as a new build action.
*/
@Extension
public static final class RunListenerImpl extends RunListener<AbstractBuild<?, ?>> {
public static final class RunListenerImpl extends RunListener<Run<?, ?>> {

@Override
public void onCompleted(final AbstractBuild<?, ?> run, final TaskListener listener) {
public void onCompleted(final Run<?, ?> run, final TaskListener listener) {
if (run.getAction(TestEnvInvisibleAction.class) != null) {
run.addAction(new TestEnvActionView(run, listener));
}
Expand Down

0 comments on commit 0cd8a44

Please sign in to comment.