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

[JENKINS-57921] - Add SelfPromotionStep for Pipeline jobs #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@
</build>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.6</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package hudson.plugins.promoted_builds;

import com.google.common.collect.ImmutableSet;
import hudson.Extension;
import hudson.model.Run;
import hudson.model.TaskListener;
import org.apache.commons.lang.StringUtils;
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.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.util.Set;


public class SelfPromotionStep extends Step {
@CheckForNull
private String job;

// @Param(name="job")
@DataBoundConstructor
public SelfPromotionStep(String job){

this.job = StringUtils.trimToNull(job);
}

public String getJob(){

return job;
}
public void setJob(String Job){

this.job = StringUtils.trimToNull(job);
}
// Confusion!!!!!!
/*public StepExecution start(StepContext context) throws Exception{
return new Execution(context,this);
}**/

@Extension
public static class DescriptorImpl extends StepDescriptor {

@Override
public String getFunctionName(){
return "selfPromote";
}

@Override
public String getDisplayName(){
return "Self Promotion";}

@Override
public Set<Class<?>> getRequiredContext(){
return ImmutableSet.of(Run.class, TaskListener.class);
}
}
// Confusion
/* public static class Execution extends SynchronousStepExecution<Void>{
Execution(@Nonnull StepContext context, @Nonnull SelfPromotionStep step){
super(context);
this.step = step;
}*/

private static final long serialVersionUID = 1L;
}
}
}