Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,19 @@ public void createJob(FolderJob folder, String jobName, String jobXml) throws IO
public void createJob(FolderJob folder, String jobName, String jobXml, Boolean crumbFlag) throws IOException {
client.post_xml(toBaseUrl(folder) + "createItem?name=" + EncodingUtils.encodeParam(jobName), jobXml, crumbFlag);
}

/**
* Copy a job from onther already exists job
*
* @param fromName from job name
* @param jobName target job name
* @throws IOException
*/
public void copyJob(String fromName, String jobName) throws IOException {
client.post(String.format("/createItem?mode=copy&from=%s&name=%s",
EncodingUtils.encodeParam(fromName),
EncodingUtils.encodeParam(jobName)));
}

/**
* Create a view on the server using the provided xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.mockito.Matchers.eq;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -222,6 +223,12 @@ public void testCreateJob() throws Exception {
String xmlReturn = captureString.getValue();
assertEquals(xmlReturn, xmlString);
}

@Test
public void testCopyJob() throws Exception {
String oldName = "pipeline";
server.copyJob(oldName, oldName + "_" + System.currentTimeMillis());
}

@Test
public void testJenkinsConnectivity() throws IOException {
Expand Down