Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing deprecations and updating POM #17

Merged
merged 1 commit into from
Jun 23, 2017
Merged
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
15 changes: 8 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.27</version>
<version>2.30</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -40,16 +40,17 @@
<properties>
<jenkins.version>2.60</jenkins.version>
<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgotten in #15.

<scm-api-plugin.version>2.1.1</scm-api-plugin.version>
<git-plugin.version>3.3.0</git-plugin.version>
<subversion-plugin.version>2.8</subversion-plugin.version>
<workflow-step-api-plugin.version>2.9</workflow-step-api-plugin.version>
<workflow-support-plugin.version>2.14</workflow-support-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.9</version>
<version>${workflow-step-api-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down Expand Up @@ -105,7 +106,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.9</version>
<version>${workflow-step-api-plugin.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -148,14 +149,14 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.14</version>
<classifier>tests</classifier>
<version>${workflow-support-plugin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.14</version>
<version>${workflow-support-plugin.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,30 @@

package org.jenkinsci.plugins.workflow.steps.scm;

import com.google.common.collect.ImmutableSet;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.listeners.SCMListener;
import hudson.scm.SCM;
import hudson.scm.SCMRevisionState;

import java.io.File;
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import javax.annotation.Nonnull;
import javax.inject.Inject;

import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;
import org.jenkinsci.plugins.workflow.steps.StepContextParameter;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.steps.StepContext;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
import org.jenkinsci.plugins.workflow.steps.StepExecution;
import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution;
import org.kohsuke.stapler.DataBoundSetter;

/**
* A step which uses some kind of {@link SCM}.
*/
public abstract class SCMStep extends AbstractStepImpl implements Serializable {
public abstract class SCMStep extends Step {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serializable seems to be left over from jenkinsci/pipeline-plugin@f6d57d3 when the StepExecution was an inner class.


private boolean poll = true;
private boolean changelog = true;
Expand All @@ -70,19 +68,26 @@ public boolean isChangelog() {
this.changelog = changelog;
}

@Override public StepExecution start(StepContext context) throws Exception {
return new StepExecutionImpl(this, context);
}

protected abstract @Nonnull SCM createSCM();

public static final class StepExecutionImpl extends AbstractSynchronousNonBlockingStepExecution<Map<String,String>> {
public static final class StepExecutionImpl extends SynchronousNonBlockingStepExecution<Map<String,String>> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be the first step in fixing JENKINS-44838.


private transient final SCMStep step;

@Inject private transient SCMStep step;
@StepContextParameter private transient Run<?,?> run;
@StepContextParameter private transient FilePath workspace;
@StepContextParameter private transient TaskListener listener;
@StepContextParameter private transient Launcher launcher;
StepExecutionImpl(SCMStep step, StepContext context) {
super(context);
this.step = step;
}

@Override
protected Map<String,String> run() throws Exception {
step.checkout(run, workspace, listener, launcher);
StepContext ctx = getContext();
Run<?, ?> run = ctx.get(Run.class);
step.checkout(run, ctx.get(FilePath.class), ctx.get(TaskListener.class), ctx.get(Launcher.class));
Map<String,String> envVars = new TreeMap<>();
step.createSCM().buildEnvironment(run, envVars);
return envVars;
Expand Down Expand Up @@ -127,16 +132,14 @@ public final void checkout(Run<?,?> run, FilePath workspace, TaskListener listen
l.onCheckout(run, scm, workspace, listener, changelogFile, pollingBaseline);
}
scm.postCheckout(run, launcher, workspace, listener);
// TODO should we call buildEnvVars and return the result?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obsolete as of #16

}

public static abstract class SCMStepDescriptor extends AbstractStepDescriptorImpl {
public static abstract class SCMStepDescriptor extends StepDescriptor {

protected SCMStepDescriptor() {
super(StepExecutionImpl.class);
@Override public Set<? extends Class<?>> getRequiredContext() {
return ImmutableSet.of(Run.class, FilePath.class, TaskListener.class, Launcher.class);
}

}

private static final long serialVersionUID = 1L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void scmVars() throws Exception {
" ws {\n" +
" git($/" + sampleGitRepo + "/$)\n" +
" }\n" +
"}"));
"}", true));
p.save();
WorkflowRun b = r.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
r.j.assertLogContains("Cloning the remote Git repository", b);
Expand Down Expand Up @@ -134,7 +134,7 @@ public void scmVars() throws Exception {
p.setDefinition(new CpsFlowDefinition(
"semaphore 'before'\n" +
"node {svn '" + sampleSvnRepo.trunkUrl() + "'}\n" +
"semaphore 'after'"));
"semaphore 'after'", true));
assertPolling(p, PollingResult.Change.INCOMPARABLE);
WorkflowRun b1 = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.success("before/1", null);
Expand Down