use of hudson.tasks.ArtifactArchiver in project blueocean-plugin by jenkinsci.
the class AbstractRunImplTest method testArtifactZipFileLink.
@Test
public void testArtifactZipFileLink() throws Exception {
String JOB_NAME = "artifactTest";
FreeStyleProject p = j.createFreeStyleProject(JOB_NAME);
p.getBuildersList().add(new Shell("touch {{a..z},{A..Z},{0..99}}.txt"));
p.getPublishersList().add(new ArtifactArchiver("*"));
Run r = p.scheduleBuild2(0).waitForStart();
r = j.waitForCompletion(r);
Map m = request().get("/organizations/jenkins/pipelines/" + JOB_NAME + "/runs/" + r.getId() + "/").build(Map.class);
Assert.assertEquals(m.get("artifactsZipFile"), "/job/artifactTest/1/artifact/*zip*/archive.zip");
}
use of hudson.tasks.ArtifactArchiver 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.tasks.ArtifactArchiver 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.tasks.ArtifactArchiver in project promoted-builds-plugin by jenkinsci.
the class PromotionProcessTest method test1.
@Test
public void test1() throws Exception {
FreeStyleProject up = j.createFreeStyleProject("up");
FreeStyleProject down = j.createFreeStyleProject();
Recorder r1 = new ArtifactArchiver("a.jar", null, false);
Recorder r2 = new Fingerprinter("", true);
List<Recorder> recorders = Arrays.asList(r1, r2);
// upstream job
up.getBuildersList().add(Functions.isWindows() ? new BatchFile("date /t > a.jar") : new Shell("date > a.jar"));
up.getPublishersList().replaceBy(recorders);
// promote if the downstream passes
JobPropertyImpl promotion = new JobPropertyImpl(up);
up.addProperty(promotion);
PromotionProcess proc = promotion.addProcess("promo");
proc.conditions.add(new DownstreamPassCondition(down.getName()));
// this is the test job
String baseUrl = j.createWebClient().getContextPath() + "job/up/lastSuccessfulBuild";
String artifactUrl = baseUrl + "/artifact/a.jar";
down.getBuildersList().add(Functions.isWindows() ? new BatchFile("powershell -command \"Invoke-WebRequest " + artifactUrl + " -OutFile a.jar\"\r\n" + "set /a \"exitCode=BUILD_NUMBER%%2\"\r\n" + "exit /b %exitCode%\r\n") : new Shell("wget -N " + artifactUrl + " \\\n" + " || curl " + artifactUrl + " > a.jar\n" + // expr exits with non-zero status if result is zero
"expr $BUILD_NUMBER % 2 - 1\n"));
down.getPublishersList().replaceBy(recorders);
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
// not yet promoted while the downstream is failing
FreeStyleBuild up1 = j.assertBuildStatusSuccess(up.scheduleBuild2(0).get());
j.assertBuildStatus(Result.FAILURE, down.scheduleBuild2(0).get());
// give it a time to not promote
Thread.sleep(1000);
assertEquals(0, proc.getBuilds().size());
// a successful downstream build promotes upstream
j.assertBuildStatusSuccess(down.scheduleBuild2(0).get());
// give it a time to promote
Thread.sleep(1000);
assertEquals(1, proc.getBuilds().size());
{
// verify that it promoted the right stuff
Promotion pb = proc.getBuilds().get(0);
assertSame(pb.getTargetBuildOrFail(), up1);
PromotedBuildAction badge = (PromotedBuildAction) up1.getBadgeActions().get(0);
assertTrue(badge.contains(proc));
}
// make sure the UI persists the setup
j.configRoundtrip(up);
}
use of hudson.tasks.ArtifactArchiver in project hudson-2.x by hudson.
the class FailureBuildMail method artifactMatches.
/**
* Check whether a path (/-separated) will be archived.
*/
public boolean artifactMatches(String path, AbstractBuild<?, ?> build) {
ArtifactArchiver aa = build.getProject().getPublishersList().get(ArtifactArchiver.class);
if (aa == null) {
// LOGGER.finer("No ArtifactArchiver found");
return false;
}
String artifacts = aa.getArtifacts();
for (String include : artifacts.split("[, ]+")) {
String pattern = include.replace(File.separatorChar, '/');
if (pattern.endsWith("/")) {
pattern += "**";
}
if (SelectorUtils.matchPath(pattern, path)) {
// new Object[]{path, pattern});
return true;
}
}
// new Object[]{path, artifacts});
return false;
}
Aggregations