Skip to content
Open
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
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.392</version>
<relativePath>../pom.xml</relativePath>
<version>1.420</version>
</parent>

<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>URLSCM</artifactId>
<packaging>hpi</packaging>
<version>1.7-SNAPSHOT</version>
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/hudson/plugins/URLSCM/URLDateAction.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package hudson.plugins.URLSCM;

import hudson.model.Action;
import hudson.model.AbstractBuild;
import hudson.model.AbstractModelObject;
import hudson.scm.SCMRevisionState;

import java.io.IOException;
import java.text.DateFormat;
Expand All @@ -15,21 +14,18 @@
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

public class URLDateAction extends AbstractModelObject implements Action {
/**
*
*/
private static final long serialVersionUID = 1L;
public class URLDateAction extends SCMRevisionState {
private static final long serialVersionUID = 1L;

private final HashMap<String, Long> lastModified = new HashMap<String, Long>();
private final HashMap<String, Long> lastModified = new HashMap<String, Long>();

private final AbstractBuild build;
private final AbstractBuild<?, ?> build;

protected URLDateAction(final AbstractBuild build) {
protected URLDateAction(final AbstractBuild<?, ?> build) {
this.build = build;
}

public AbstractBuild getBuild() {
public AbstractBuild<?, ?> getBuild() {
return build;
}

Expand Down Expand Up @@ -60,10 +56,12 @@ public Map<String, String> getUrlDates() {
return ret;
}

@Override
public String getDisplayName() {
return "URL Modification Dates";
}

@Override
public String getIconFileName() {
return "save.gif";
}
Expand All @@ -72,6 +70,7 @@ public String getSearchUrl() {
return getUrlName();
}

@Override
public String getUrlName() {
return "urlDates";
}
Expand Down
46 changes: 18 additions & 28 deletions src/main/java/hudson/plugins/URLSCM/URLSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Run;
import hudson.scm.ChangeLogParser;
import hudson.scm.NullChangeLogParser;
import hudson.scm.PollingResult;
Expand Down Expand Up @@ -118,20 +117,26 @@ public boolean requiresWorkspaceForPolling() {
}

@Override
public boolean pollChanges(final AbstractProject project,
final Launcher launcher, final FilePath workspace,
final TaskListener listener) throws IOException,
public SCMRevisionState calcRevisionsFromBuild(
final AbstractBuild<?, ?> project, final Launcher launcher,
final TaskListener listener) throws IOException, InterruptedException {
return null;
}

@Override
protected PollingResult compareRemoteRevisionWith(
final AbstractProject<?, ?> project, final Launcher launcher,
final FilePath workspace, final TaskListener listener,
final SCMRevisionState state) throws IOException,
InterruptedException {
boolean change = false;
final Run lastBuild = project.getLastBuild();
if (lastBuild == null) {
return true;
}
final URLDateAction dates = lastBuild.getAction(URLDateAction.class);
if (dates == null) {
return true;

if (state == null || !(state instanceof URLDateAction)) {
listener.getLogger().println("Changes not yet tracked with last build, triggering a new one");
return PollingResult.BUILD_NOW;
}

final URLDateAction dates = (URLDateAction) state;
for (final URLTuple tuple : urls) {
final String urlString = tuple.getUrl();
try {
Expand All @@ -155,9 +160,9 @@ public boolean pollChanges(final AbstractProject project,
+ e.getMessage());
}
}
return change;
return change ? PollingResult.BUILD_NOW : PollingResult.NO_CHANGES;
}

public static final class URLTuple {
private final String urlString;

Expand Down Expand Up @@ -225,19 +230,4 @@ protected FormValidation check() throws IOException,
}
}

@Override
public SCMRevisionState calcRevisionsFromBuild(
final AbstractBuild<?, ?> arg0, final Launcher arg1,
final TaskListener arg2) throws IOException, InterruptedException {
return null;
}

@Override
protected PollingResult compareRemoteRevisionWith(
final AbstractProject<?, ?> arg0, final Launcher arg1,
final FilePath arg2, final TaskListener arg3,
final SCMRevisionState arg4) throws IOException,
InterruptedException {
return PollingResult.BUILD_NOW;
}
}