Skip to content

Commit

Permalink
JENKINS-12320 Included a dependency on copy-to-slave plugin to handle…
Browse files Browse the repository at this point in the history
… copying sauce connect jar to slave
  • Loading branch information
rossrowe committed Jan 20, 2012
1 parent 4cb72f4 commit c135313
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 58 deletions.
64 changes: 35 additions & 29 deletions pom.xml
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down Expand Up @@ -33,7 +34,7 @@
</configuration>
</plugin>
</plugins>

</build>

<dependencies>
Expand Down Expand Up @@ -79,25 +80,25 @@
<groupId>com.saucelabs</groupId>
<artifactId>sauce-rest-api</artifactId>
<version>1.5</version>
</dependency>
</dependency>
<!-- ci-sauce is contained in the https://repository-saucelabs.forge.cloudbees.com/release Maven repository -->
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>ci-sauce</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium.client-drivers</groupId>
<artifactId>selenium-java-client-driver</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
<!-- Sauce Connect is contained in the https://repository-saucelabs.forge.cloudbees.com/release Maven repository -->
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>ci-sauce</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium.client-drivers</groupId>
<artifactId>selenium-java-client-driver</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
<!-- Sauce Connect is contained in the https://repository-saucelabs.forge.cloudbees.com/release Maven repository -->
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>sauce-connect</artifactId>
<version>3.0</version>
<version>3.0.18</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -123,6 +124,11 @@
<artifactId>jackson-mapper-asl</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>copy-to-slave</artifactId>
<version>1.4</version>
</dependency>
<!-- Include Guava dependency to avoid compile errors -->
<dependency>
<groupId>com.google.guava</groupId>
Expand All @@ -137,16 +143,16 @@
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
</pluginRepository>
</pluginRepositories>
</project>
Expand Up @@ -23,6 +23,7 @@
*/
package hudson.plugins.sauce_ondemand;

import com.michelin.cio.hudson.plugins.copytoslave.MyFilePath;
import com.saucelabs.ci.sauceconnect.SauceConnectTwoManager;
import com.saucelabs.ci.sauceconnect.SauceConnectUtils;
import com.saucelabs.ci.sauceconnect.SauceTunnelManager;
Expand All @@ -35,8 +36,6 @@
import hudson.remoting.Channel;
import hudson.tasks.BuildWrapper;
import hudson.util.Secret;
import org.apache.tools.ant.taskdefs.Copy;
import org.apache.tools.ant.types.FileSet;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.File;
Expand Down Expand Up @@ -123,39 +122,23 @@ public boolean tearDown(AbstractBuild build, BuildListener listener) throws IOEx
}

private File copySauceConnectToSlave(AbstractBuild build, BuildListener listener) throws IOException {
class CopyImpl extends Copy {
private int copySize;

public CopyImpl() {
setProject(new org.apache.tools.ant.Project());
}

@Override
protected void doFileOperations() {
copySize = super.fileCopyMap.size();
super.doFileOperations();
}

public int getNumCopied() {
return copySize;
}
}

FilePath projectWorkspaceOnSlave = build.getProject().getWorkspace();
FilePath projectWorkspaceOnSlave = build.getProject().getSomeWorkspace();
try {
File sauceConnectJar = SauceConnectUtils.extractSauceConnectJarFile();
FileSet fs = Util.createFileSet(sauceConnectJar.getParentFile(), sauceConnectJar.getName(), "");
CopyImpl copyTask = new CopyImpl();
copyTask.setTodir(new File(projectWorkspaceOnSlave.getRemote()));
copyTask.addFileset(fs);
copyTask.setOverwrite(true);
copyTask.setIncludeEmptyDirs(false);
copyTask.setFlatten(false);

copyTask.execute();
//FileSet fs = Util.createFileSet(sauceConnectJar.getParentFile(), sauceConnectJar.getName(), "");

MyFilePath.copyRecursiveTo(
new FilePath(sauceConnectJar.getParentFile()),
sauceConnectJar.getName(),
null,
false, false, projectWorkspaceOnSlave);

return new File(projectWorkspaceOnSlave.getRemote(), sauceConnectJar.getName());
} catch (URISyntaxException e) {
listener.error("Error copying sauce connect jar to slave", e);
} catch (InterruptedException e) {
listener.error("Error copying sauce connect jar to slave", e);
}
return null;
}
Expand Down

0 comments on commit c135313

Please sign in to comment.