forked from prospero238/liquibase-runner
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
creation of update pipeline class, allowing "liquibaseUpdate" to be used in pipeline script
- Loading branch information
1 parent
f87003e
commit 1670566
Showing
7 changed files
with
356 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 198 additions & 0 deletions
198
src/main/java/org/jenkinsci/plugins/liquibase/workflow/LiquibaseUpdateBuildStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
package org.jenkinsci.plugins.liquibase.workflow; | ||
|
||
import hudson.Extension; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl; | ||
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
|
||
public class LiquibaseUpdateBuildStep extends AbstractStepImpl { | ||
protected String databaseEngine; | ||
protected String changeLogFile; | ||
protected String url; | ||
protected String defaultSchemaName; | ||
protected String contexts; | ||
protected String liquibasePropertiesPath; | ||
protected String classpath; | ||
protected String driverClassname; | ||
protected String labels; | ||
private String changeLogParameters; | ||
private String basePath; | ||
private Boolean useIncludedDriver; | ||
private String credentialsId; | ||
protected boolean testRollbacks; | ||
private boolean dropAll; | ||
protected boolean tagOnSuccessfulBuild; | ||
|
||
@DataBoundConstructor | ||
public LiquibaseUpdateBuildStep(String changeLogFile) { | ||
this.changeLogFile = changeLogFile; | ||
} | ||
|
||
|
||
@Extension | ||
public static final class DescriptorImpl extends AbstractStepDescriptorImpl { | ||
|
||
public DescriptorImpl() { | ||
super(LiquibaseUpdateExecution.class); | ||
} | ||
|
||
@Override | ||
public String getFunctionName() { | ||
return "liquibaseUpdate"; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getDisplayName() { | ||
return "Evaluate liquibase changesets"; | ||
} | ||
} | ||
|
||
@DataBoundSetter | ||
public void setDatabaseEngine(String databaseEngine) { | ||
this.databaseEngine = databaseEngine; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setChangeLogFile(String changeLogFile) { | ||
this.changeLogFile = changeLogFile; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setDefaultSchemaName(String defaultSchemaName) { | ||
this.defaultSchemaName = defaultSchemaName; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setContexts(String contexts) { | ||
this.contexts = contexts; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setLiquibasePropertiesPath(String liquibasePropertiesPath) { | ||
this.liquibasePropertiesPath = liquibasePropertiesPath; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setClasspath(String classpath) { | ||
this.classpath = classpath; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setDriverClassname(String driverClassname) { | ||
this.driverClassname = driverClassname; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setLabels(String labels) { | ||
this.labels = labels; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setChangeLogParameters(String changeLogParameters) { | ||
this.changeLogParameters = changeLogParameters; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setBasePath(String basePath) { | ||
this.basePath = basePath; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setUseIncludedDriver(Boolean useIncludedDriver) { | ||
this.useIncludedDriver = useIncludedDriver; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setCredentialsId(String credentialsId) { | ||
this.credentialsId = credentialsId; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setTestRollbacks(boolean testRollbacks) { | ||
this.testRollbacks = testRollbacks; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setDropAll(boolean dropAll) { | ||
this.dropAll = dropAll; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setTagOnSuccessfulBuild(boolean tagOnSuccessfulBuild) { | ||
this.tagOnSuccessfulBuild = tagOnSuccessfulBuild; | ||
} | ||
|
||
public String getDatabaseEngine() { | ||
return databaseEngine; | ||
} | ||
|
||
public String getChangeLogFile() { | ||
return changeLogFile; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getDefaultSchemaName() { | ||
return defaultSchemaName; | ||
} | ||
|
||
public String getContexts() { | ||
return contexts; | ||
} | ||
|
||
public String getLiquibasePropertiesPath() { | ||
return liquibasePropertiesPath; | ||
} | ||
|
||
public String getClasspath() { | ||
return classpath; | ||
} | ||
|
||
public String getDriverClassname() { | ||
return driverClassname; | ||
} | ||
|
||
public String getLabels() { | ||
return labels; | ||
} | ||
|
||
public String getChangeLogParameters() { | ||
return changeLogParameters; | ||
} | ||
|
||
public String getBasePath() { | ||
return basePath; | ||
} | ||
|
||
public Boolean getUseIncludedDriver() { | ||
return useIncludedDriver; | ||
} | ||
|
||
public String getCredentialsId() { | ||
return credentialsId; | ||
} | ||
|
||
public boolean isTestRollbacks() { | ||
return testRollbacks; | ||
} | ||
|
||
public boolean isDropAll() { | ||
return dropAll; | ||
} | ||
|
||
public boolean isTagOnSuccessfulBuild() { | ||
return tagOnSuccessfulBuild; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/org/jenkinsci/plugins/liquibase/workflow/LiquibaseUpdateExecution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.jenkinsci.plugins.liquibase.workflow; | ||
|
||
import hudson.EnvVars; | ||
import hudson.FilePath; | ||
import hudson.Launcher; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
|
||
import org.jenkinsci.plugins.liquibase.evaluator.ChangesetEvaluator; | ||
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution; | ||
import org.jenkinsci.plugins.workflow.steps.StepContextParameter; | ||
|
||
import com.google.inject.Inject; | ||
|
||
public class LiquibaseUpdateExecution extends AbstractSynchronousStepExecution<Void> { | ||
|
||
@Inject | ||
private transient LiquibaseUpdateBuildStep step; | ||
|
||
@StepContextParameter | ||
private transient TaskListener listener; | ||
|
||
@StepContextParameter | ||
private transient Launcher launcher; | ||
|
||
@StepContextParameter | ||
private transient Run<?, ?> run; | ||
|
||
@StepContextParameter | ||
private transient FilePath ws; | ||
|
||
@StepContextParameter | ||
private transient EnvVars envVars; | ||
|
||
|
||
@Override | ||
protected Void run() throws Exception { | ||
ChangesetEvaluator changesetEvaluator = new ChangesetEvaluator(); | ||
changesetEvaluator.setDatabaseEngine(step.getDatabaseEngine()); | ||
changesetEvaluator.setChangeLogFile(step.getChangeLogFile()); | ||
changesetEvaluator.setUrl(step.getUrl()); | ||
changesetEvaluator.setDefaultSchemaName(step.getDefaultSchemaName()); | ||
changesetEvaluator.setContexts(step.getContexts()); | ||
changesetEvaluator.setLiquibasePropertiesPath(step.getLiquibasePropertiesPath()); | ||
changesetEvaluator.setClasspath(step.getClasspath()); | ||
changesetEvaluator.setDriverClassname(step.getDriverClassname()); | ||
changesetEvaluator.setLabels(step.getLabels()); | ||
changesetEvaluator.setChangeLogParameters(step.getChangeLogParameters()); | ||
changesetEvaluator.setBasePath(step.getBasePath()); | ||
changesetEvaluator.setUseIncludedDriver(step.getUseIncludedDriver()); | ||
|
||
|
||
changesetEvaluator.setTestRollbacks(step.isTestRollbacks()); | ||
changesetEvaluator.setDropAll(step.isDropAll()); | ||
changesetEvaluator.setTagOnSuccessfulBuild(step.isTagOnSuccessfulBuild()); | ||
|
||
|
||
changesetEvaluator.perform(run, ws, launcher, listener); | ||
return null; | ||
|
||
} | ||
} |
Oops, something went wrong.