private void scheduleImediatePollingOfJob(Job job, SCMTrigger trigger, List<SvnInfo> infos) { LOGGER.fine("Scheduling the immediate polling of " + job); final RevisionParameterAction[] actions; if (infos.isEmpty()) { actions = new RevisionParameterAction[0]; } else { actions = new RevisionParameterAction[] { new RevisionParameterAction(infos) }; } trigger.run(actions); }
public void foldIntoExisting(Queue.Item item, Task owner, List<Action> otherActions) { RevisionParameterAction existing = item.getAction(RevisionParameterAction.class); if (existing!=null) { existing.mergeRevisions(this.revisions); return; } // no RevisionParameterAction found, so add a copy of this one item.getActions().add(new RevisionParameterAction(this)); }
@Override public Action getAction(AbstractBuild<?,?> build, TaskListener listener) { SubversionTagAction tagAction = build.getAction(SubversionTagAction.class); RevisionParameterAction revisionAction = build.getAction(RevisionParameterAction.class); List<SvnInfo> infos = new ArrayList<SvnInfo>(); if (tagAction == null ) { listener.getLogger().println( Plugin.LOG_TAG + " no SubversionTagAction found -- is this project an SVN project ?"); } else { infos.addAll(tagAction.getTags().keySet()); } if(includeUpstreamParameters == true) { if (revisionAction == null ) { listener.getLogger().println( Plugin.LOG_TAG + " no RevisionParameterAction found -- project did not have SVN parameters passed to it?"); } else { infos.addAll(revisionAction.getRevisions()); } } //if infos is empty don't return an action. return (infos.size() == 0 ) ? null : new RevisionParameterAction(infos); }
/** * Determines the revision to check out for the given location. */ protected SVNRevision getRevision(ModuleLocation l) { // for the SVN revision, we will use the first off: // - a @NNN suffix of the SVN url // - a value found in a RevisionParameterAction // - the revision corresponding to the build timestamp SVNRevision r = null; if (revisions != null) { r = revisions.getRevision(l.getURL()); } if (r == null) { r = SVNRevision.create(timestamp); } r = l.getRevision(r); return r; }
/** * Tests a checkout triggered from the post-commit hook */ @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void postCommitTriggerMultipleSvnLocations() throws Exception { FreeStyleProject p = createPostCommitTriggerJobMultipleSvnLocations(); FreeStyleBuild b = sendCommitTriggerMultipleSvnLocations(p, true); assertTrue(getActualRevision(b, "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant") <= 18075); Long actualRevision = getActualRevision(b, "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-maven"); assertEquals(Long.valueOf(18075), actualRevision); List<RevisionParameterAction> actions = b.getActions(RevisionParameterAction.class); assertEquals(1, actions.size()); RevisionParameterAction action = actions.get(0); assertEquals(2, action.getRevisions().size()); }
SVNRevision revision = revisionParameterAction.getRevision(location.getURL()); if(revision != null) { return revisionParameterAction.getRevision(location.getURL());
@Override public Action getAction(AbstractBuild<?,?> build, TaskListener listener) { SubversionTagAction tagAction = build.getAction(SubversionTagAction.class); if (tagAction == null) { listener.getLogger().println( "[parameterizedtrigger] no SubversionTagAction found -- is this project an SVN project ?"); return null; } List<SvnInfo> infos = new ArrayList<SvnInfo>(tagAction.getTags().keySet()); return new RevisionParameterAction(infos); }
public void foldIntoExisting(Queue.Item item, Task owner, List<Action> otherActions) { RevisionParameterAction existing = item.getAction(RevisionParameterAction.class); if (existing!=null) { existing.mergeRevisions(this.revisions); return; } // no RevisionParameterAction found, so add a copy of this one item.getActions().add(new RevisionParameterAction(this)); }
SVNRevision revision = revisionParameterAction.getRevision(location.getURL()); if(revision != null) { return revisionParameterAction.getRevision(location.getURL());
if ( rev != -1 ) { SvnInfo info[] = { new SvnInfo(loc.getURL(), rev) }; RevisionParameterAction action = new RevisionParameterAction(info); actions = new RevisionParameterAction[] {action};
public void foldIntoExisting(Queue.Item item, Task owner, List<Action> otherActions) { RevisionParameterAction existing = item.getAction(RevisionParameterAction.class); if (existing!=null) { existing.mergeRevisions(this.revisions); return; } // no RevisionParameterAction found, so add a copy of this one item.getActions().add(new RevisionParameterAction(this)); }
if (rev != -1) { SvnInfo info[] = {new SvnInfo(loc.getURL(), rev)}; RevisionParameterAction action = new RevisionParameterAction(info); actions = new RevisionParameterAction[]{action};
@Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void revisionParameterFolding() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); String url = "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant"; p.setScm(new SubversionSCM(url)); // Schedule build of a specific revision with a quiet period Future<FreeStyleBuild> f = p.scheduleBuild2(60, new Cause.UserIdCause(), new RevisionParameterAction(new SubversionSCM.SvnInfo(url, 13000))); // Schedule another build at a more recent revision p.scheduleBuild2(0, new Cause.UserIdCause(), new RevisionParameterAction(new SubversionSCM.SvnInfo(url, 14000))); FreeStyleBuild b = f.get(); System.out.println(b.getLog(LOG_LIMIT)); r.assertLogContains("at revision 14000", b); r.assertBuildStatus(Result.SUCCESS,b); }
@Test public void testRevisionFromRevisionParametersOverrideTimestamp() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(4711L, revision.getNumber()); assertNull(revision.getDate()); }
@Test public void testRevisionInUrlOverridesEverything() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote@12345", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(12345L, revision.getNumber()); assertNull(revision.getDate()); }
/** * Tests a checkout with RevisionParameterAction */ @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void revisionParameter() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); String url = "https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant"; p.setScm(new SubversionSCM(url)); FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserIdCause(), new RevisionParameterAction(new SubversionSCM.SvnInfo(url, 13000))).get(); System.out.println(b.getLog(LOG_LIMIT)); r.assertLogContains("at revision 13000", b); r.assertBuildStatus(Result.SUCCESS,b); }
@Test public void testRevisionInUrlOverridesEverything_HEAD() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote@HEAD", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(SVNRevision.HEAD.getName(), revision.getName()); assertEquals(-1L, revision.getNumber()); assertNull(revision.getDate()); }