build.addAction(new SCMRevisionAction(scmSource, tip)); SCMRevision rev = scmSource.getTrustedRevision(tip, listener); try (SCMFileSystem fs = USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(scmSource, head, rev)) { if (fs != null) { // JENKINS-33273 String script = null;
build.addAction(new SCMRevisionAction(tip)); SCMRevision rev = scmSource.getTrustedRevision(tip, listener); try (SCMFileSystem fs = USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(scmSource, head, rev)) { if (fs != null) { // JENKINS-33273 String script = null;
String expandedScriptPath = build.getEnvironment(listener).expand(scriptPath); if (isLightweight()) { try (SCMFileSystem fs = SCMFileSystem.of(build.getParent(), scm)) { if (fs != null) { String script = fs.child(expandedScriptPath).contentAsString();
@Test public void ofSourceRevision() throws Exception { sampleRepo.init(); sampleRepo.svnkit("copy", "--message=branching", sampleRepo.trunkUrl(), sampleRepo.branchesUrl() + "/dev"); sampleRepo.svnkit("switch", sampleRepo.branchesUrl() + "/dev", sampleRepo.wc()); SCMSource source = new SubversionSCMSource(null, sampleRepo.prjUrl()); SCMRevision revision = source.fetch(new SCMHead("branches/dev"), null); sampleRepo.write("file", "modified"); sampleRepo.svnkit("commit", "--message=dev1", sampleRepo.wc()); try (SCMFileSystem fs = SCMFileSystem.of(source, new SCMHead("branches/dev"), revision)) { assertThat(fs, notNullValue()); SCMFile root = fs.getRoot(); assertThat(root, notNullValue()); Iterable<SCMFile> children = root.children(); Iterator<SCMFile> iterator = children.iterator(); assertThat(iterator.hasNext(), is(true)); SCMFile file = iterator.next(); assertThat(iterator.hasNext(), is(false)); assertThat(file.getName(), is("file")); assertThat(file.contentAsString(), is("")); } }
sampleRepo.svnkit("commit", "--message=dev1", sampleRepo.wc()); SCMSource source = new SubversionSCMSource(null, sampleRepo.prjUrl()); try (SCMFileSystem fs = SCMFileSystem.of(source, new SCMHead("branches/dev"))) { assertThat(fs, notNullValue()); assertThat(fs.getRoot(), notNullValue());
try (SCMFileSystem fs = SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(job, standaloneSCM)) { if (fs != null) { // JENKINS-33273 try { String untrustedFile = null; String content; try (SCMFileSystem tipFS = trustCheck && !SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? SCMFileSystem.of(scmSource, head, tip) : null; SCMFileSystem trustedFS = SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(scmSource, head, trusted)) { if (trustedFS != null && (!trustCheck || tipFS != null)) { if (trustCheck) {
try (SCMFileSystem fs = SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(job, standaloneSCM)) { if (fs != null) { // JENKINS-33273 try { String untrustedFile = null; String content; try (SCMFileSystem tipFS = trustCheck && !SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? SCMFileSystem.of(scmSource, head, tip) : null; SCMFileSystem trustedFS = SCMBinder.USE_HEAVYWEIGHT_CHECKOUT ? null : SCMFileSystem.of(scmSource, head, trusted)) { if (trustedFS != null && (!trustCheck || tipFS != null)) { if (trustCheck) {
sampleRepo.svnkit("commit", "--message=dev1", sampleRepo.wc()); SCMSource source = new SubversionSCMSource(null, sampleRepo.prjUrl()); try (SCMFileSystem fs = SCMFileSystem.of(source, new SCMHead("branches/dev"));) { assertThat(fs, notNullValue()); assertThat(fs.getRoot(), notNullValue());
assertEquals(7, dev2); SCMSource source = new SubversionSCMSource(null, sampleRepo.prjUrl()); try (SCMFileSystem fs = SCMFileSystem.of(source, new SCMHead("trunk"))) { assertThat(fs, notNullValue()); SCMFile root = fs.getRoot();
@Test public void lastModified_Smokes() throws Exception { long currentTime = isWindows() ? System.currentTimeMillis() / 1000L * 1000L : System.currentTimeMillis(); sampleRepo.init(); sampleRepo.svnkit("copy", "--message=branching", sampleRepo.trunkUrl(), sampleRepo.branchesUrl() + "/dev"); sampleRepo.svnkit("switch", sampleRepo.branchesUrl() + "/dev", sampleRepo.wc()); SCMSource source = new SubversionSCMSource(null, sampleRepo.prjUrl()); SCMRevision revision = source.fetch(new SCMHead("branches/dev"), null); long oneMinute = 60*1000; sampleRepo.write("file", "modified"); sampleRepo.svnkit("commit", "--message=dev1", sampleRepo.wc()); try (SCMFileSystem fs = SCMFileSystem.of(source, new SCMHead("branches/dev"), revision);) { long lastModified = fs.lastModified(); //ensure the timestamp is from after we started but not in the distant future assertThat(lastModified, greaterThanOrEqualTo(currentTime)); assertThat(lastModified, lessThanOrEqualTo(currentTime + oneMinute)); SCMFile file = fs.getRoot().child("file"); lastModified = file.lastModified(); assertThat(lastModified, greaterThanOrEqualTo(currentTime)); assertThat(lastModified, lessThanOrEqualTo(currentTime + oneMinute)); } }