use of hudson.Launcher in project support-core-plugin by jenkinsci.
the class SlaveCommandStatisticsTest method smokes.
@Test
public void smokes() throws Exception {
DumbSlave s = r.createSlave();
FreeStyleProject p = r.createFreeStyleProject();
p.setAssignedNode(s);
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
build.getWorkspace().act(new SampleCallable());
return true;
}
});
r.buildAndAssertSuccess(p);
String dump = SupportTestUtils.invokeComponentToString(ExtensionList.lookupSingleton(SlaveCommandStatistics.class));
System.out.println(dump);
assertThat(dump, containsString(SampleCallable.class.getName()));
}
use of hudson.Launcher in project artifact-manager-s3-plugin by jenkinsci.
the class JCloudsArtifactManagerTest method artifactBrowsingPerformance.
@Test
public void artifactBrowsingPerformance() throws Exception {
ArtifactManagerConfiguration.get().getArtifactManagerFactories().add(getArtifactManagerFactory());
FreeStyleProject p = j.createFreeStyleProject();
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath ws = build.getWorkspace();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
ws.child(i + "/" + j + "/f").write(i + "-" + j, null);
}
}
return true;
}
});
p.getPublishersList().add(new ArtifactArchiver("**"));
FreeStyleBuild b = j.buildAndAssertSuccess(p);
httpLogging.record(InvokeHttpMethod.class, Level.FINE);
httpLogging.capture(1000);
JenkinsRule.WebClient wc = j.createWebClient();
// Exercise DirectoryBrowserSupport & Run.getArtifactsUpTo
System.err.println("build root");
wc.getPage(b);
System.err.println("artifact root");
wc.getPage(b, "artifact/");
System.err.println("3 subdir");
wc.getPage(b, "artifact/3/");
System.err.println("3/4 subdir");
wc.getPage(b, "artifact/3/4/");
int httpCount = httpLogging.getRecords().size();
System.err.println("total count: " + httpCount);
assertThat(httpCount, lessThanOrEqualTo(11));
}
use of hudson.Launcher in project artifact-manager-s3-plugin by jenkinsci.
the class JCloudsArtifactManagerTest method archiveSingleLargeFile.
// @Test
public void archiveSingleLargeFile() throws Exception {
ArtifactManagerConfiguration.get().getArtifactManagerFactories().add(getArtifactManagerFactory());
FreeStyleProject p = j.createFreeStyleProject();
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath target = build.getWorkspace().child("out");
long length = 2L * 1024 * 1024 * 1024;
final FilePath src = new FilePath(Which.jarFile(Jenkins.class));
final OutputStream out = target.write();
try {
do {
IOUtils.copy(src.read(), out);
} while (target.length() < length);
} finally {
out.close();
}
return true;
}
});
p.getPublishersList().add(new ArtifactArchiver("**/*"));
FreeStyleBuild build = j.buildAndAssertSuccess(p);
InputStream out = build.getArtifactManager().root().child("out").open();
try {
IOUtils.copy(out, new NullOutputStream());
} finally {
out.close();
}
}
use of hudson.Launcher in project jenkin-qtest-plugin by QASymphony.
the class PatternScanParser method parse.
/**
* Read test results with test result location pattern
*
* @param request request
* @param testResultLocation testResultLocation
* @return a list of {@link AutomationTestResult}
* @throws Exception Exception
*/
public List<AutomationTestResult> parse(ParseRequest request, String testResultLocation) throws Exception {
JUnitParser jUnitParser = new JUnitParser(true);
Run<?, ?> build = request.getBuild();
Launcher launcher = request.getLauncher();
TaskListener listener = request.getListener();
List<TestResult> testResults = new ArrayList<>();
testResults.add(jUnitParser.parseResult(testResultLocation, build, request.getWorkSpace(), launcher, listener));
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(build.getStartTimeInMillis());
return CommonParsingUtils.toAutomationTestResults(request, testResults, gregorianCalendar.getTime());
}
use of hudson.Launcher in project workflow-job-plugin by jenkinsci.
the class WorkflowJob method poll.
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification = "TODO 1.653+ switch to Jenkins.getInstanceOrNull")
@Override
public PollingResult poll(TaskListener listener) {
if (!isBuildable()) {
listener.getLogger().println("Build disabled");
return PollingResult.NO_CHANGES;
}
// TODO 2.11+ call SCMDecisionHandler
// TODO call SCMPollListener
WorkflowRun lastBuild = getLastBuild();
if (lastBuild == null) {
listener.getLogger().println("no previous build to compare to");
// Note that we have no equivalent of AbstractProject.NoSCM because without an initial build we do not know if this project has any SCM at all.
return Queue.getInstance().contains(this) ? PollingResult.NO_CHANGES : PollingResult.BUILD_NOW;
}
WorkflowRun perhapsCompleteBuild = getLastSuccessfulBuild();
if (perhapsCompleteBuild == null) {
perhapsCompleteBuild = lastBuild;
}
if (pollingBaselines == null) {
pollingBaselines = new ConcurrentHashMap<>();
}
PollingResult result = PollingResult.NO_CHANGES;
for (WorkflowRun.SCMCheckout co : perhapsCompleteBuild.checkouts(listener)) {
if (!co.scm.supportsPolling()) {
listener.getLogger().println("polling not supported from " + co.workspace + " on " + co.node);
continue;
}
String key = co.scm.getKey();
SCMRevisionState pollingBaseline = pollingBaselines.get(key);
if (pollingBaseline == null) {
// after a restart, transient cache will be empty
pollingBaseline = co.pollingBaseline;
}
if (pollingBaseline == null) {
listener.getLogger().println("no polling baseline in " + co.workspace + " on " + co.node);
continue;
}
try {
FilePath workspace;
Launcher launcher;
WorkspaceList.Lease lease;
if (co.scm.requiresWorkspaceForPolling()) {
Jenkins j = Jenkins.getInstance();
if (j == null) {
listener.error("Jenkins is shutting down");
continue;
}
Computer c = j.getComputer(co.node);
if (c == null) {
listener.error("no such computer " + co.node);
continue;
}
workspace = new FilePath(c.getChannel(), co.workspace);
launcher = workspace.createLauncher(listener).decorateByEnv(getEnvironment(c.getNode(), listener));
lease = c.getWorkspaceList().acquire(workspace, !isConcurrentBuild());
} else {
workspace = null;
launcher = null;
lease = null;
}
PollingResult r;
try {
r = co.scm.compareRemoteRevisionWith(this, launcher, workspace, listener, pollingBaseline);
if (r.remote != null) {
pollingBaselines.put(key, r.remote);
}
} finally {
if (lease != null) {
lease.release();
}
}
if (r.change.compareTo(result.change) > 0) {
// note that if we are using >1 checkout, we can clobber baseline/remote here; anyway SCMTrigger only calls hasChanges()
result = r;
}
} catch (AbortException x) {
listener.error("polling failed in " + co.workspace + " on " + co.node + ": " + x.getMessage());
} catch (Exception x) {
// TODO 2.43+ use Functions.printStackTrace
listener.error("polling failed in " + co.workspace + " on " + co.node).println(Functions.printThrowable(x).trim());
}
}
return result;
}
Aggregations