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-40766] add pipeline support #33

Open
wants to merge 5 commits 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
74 changes: 63 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.509.3</version>
<version>2.15</version>
</parent>

<name>Jenkins Maven Release Plug-in Plug-in</name>
<description>A plug-in that enables you to perform releases using the maven-release-plugin from Jenkins.</description>
<url>http://wiki.jenkins-ci.org/display/JENKINS/M2+Release+Plugin</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.test.version>3.0.4</maven.test.version>
<!-- upd from 3.0.4 to 3.1.0 as MavenExecutionRequest.setTransferListener method is needed by jenkins -->
<maven.test.version>3.1.0</maven.test.version>
<jenkins.version>1.642.4</jenkins.version>
</properties>

<developers>
Expand Down Expand Up @@ -55,6 +55,7 @@
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.13</version>
</dependency>
<dependency>
<groupId>org.apache.maven.release</groupId>
Expand All @@ -65,6 +66,10 @@
<artifactId>maven-project</artifactId>
<groupId>org.apache.maven</groupId>
</exclusion>
<exclusion>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-providers-standard</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -73,6 +78,17 @@
<version>2.0</version>
<optional>true</optional>
</dependency>
<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>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand All @@ -91,11 +107,24 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness-tools</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.test.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- jenkins uses newer version of google guava with changes in api -->
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand All @@ -115,6 +144,35 @@
<version>${maven.test.version}</version>
<scope>test</scope>
</dependency>
<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>
</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.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -130,16 +188,10 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.96</version>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public LastReleaseListViewColumn() {

/**
* Finds the last release information of the given project.
* @param project ref to the maven project
* @return release information
*/
public Info getLastReleaseInfoOf(AbstractMavenProject<?,?> project) {
Run<?,?> r = LastReleasePermalink.INSTANCE.resolve(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ public void doSubmit(StaplerRequest req, StaplerResponse resp) throws IOExceptio

/**
* Gets the {@link ParameterDefinition} of the given name, if any.
* @param name param's name
* @return parameter definition
*/
public ParameterDefinition getParameterDefinition(String name) {
for (ParameterDefinition pd : getParameterDefinitions()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public String getUrlName() {

/**
* Gets the tooltip text that should be displayed to the user.
* @return release description, e.g. "Release (dryRun) - 1.2.3"
*/
public String getTooltipText() {
StringBuilder str = new StringBuilder();
Expand All @@ -118,6 +119,8 @@ public String getTooltipText() {

/**
* Gets the version number that was released.
*
* @return null if version can't be obtained
*/
public String getVersionNumber() {
if (versionNumber != null) {
Expand All @@ -132,7 +135,7 @@ public String getVersionNumber() {
}

/**
* Returns if the release was a dryRun or not.
* @return whether the release was a dryRun or not.
*/
public boolean isDryRun() {
if (isDryRun != null) {
Expand All @@ -147,7 +150,7 @@ public boolean isDryRun() {
}

/**
* Returns <code>true</code> if the release build job failed.
* @return <code>true</code> if the release build job failed.
*/
public boolean isFailedBuild() {
return !isSuccessfulBuild(run);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public String getDryRunGoals() {
* @return <code>true</code> if this build is a release build.
*/
private boolean isReleaseBuild(@SuppressWarnings("rawtypes") AbstractBuild build) {
return (build.getCause(ReleaseCause.class) != null);
return build.getCause(ReleaseCause.class) != null;
}


Expand Down Expand Up @@ -536,6 +536,13 @@ public boolean isNexusSupport() {

/**
* Checks if the Nexus URL exists and we can authenticate against it.
*
* @param urlValue nexus url
* @param usernameValue auth login
* @param passwordValue auth pass
* @throws IOException not used
* @throws ServletException not used
* @return server's response as <code>{@link FormValidation}</code>
*/
public FormValidation doUrlCheck(@QueryParameter String urlValue,
final @QueryParameter String usernameValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Collection<Run> getRecentReleases(int max) {
* Get the release version from this run
*
* @param run Must be a release run - i.e. have a ReleaseBuildBadgeAction
* @return
* @return result of <code>{@link M2ReleaseBadgeAction#getVersionNumber()}</code>
*/
public String getReleaseVersion(Run run) {
M2ReleaseBadgeAction rbb = run.getAction(M2ReleaseBadgeAction.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public StageClient(URL nexusURL, String username, String password) {
/**
* Get the ID for the Staging repository that holds the specified GAV.
*
* @param groupId groupID to search for.
* @param artifactId artifactID to search for.
* @param group groupID to search for.
* @param artifact artifactID to search for.
* @param version version of the group/artifact to search for - may be <code>null</code>.
* @return the stageID or null if no machine stage was found.
* @throws StageException if any issue occurred whilst locating the open stage.
Expand Down Expand Up @@ -134,6 +134,7 @@ public Stage getOpenStageID(String group, String artifact, String version) throw
* Close the specified stage.
*
* @param stage the stage to close.
* @param description description to pass to the server for the action
* @throws StageException if any issue occurred whilst closing the stage.
*/
public void closeStage(Stage stage, String description) throws StageException {
Expand Down Expand Up @@ -225,7 +226,7 @@ public void promoteStage(Stage stage) throws StageException {
* Completion of the stage action is asynchronous - so poll until the action completed.
*
* @param stage the stage to wait until the previous action is completed.
* @throws StageException
* @throws StageException a wrap for Thread.sleep
*/
protected void waitForActionToComplete(Stage stage) throws StageException {
log.debug("Waiting for {} to finish transitioning.", stage);
Expand Down Expand Up @@ -259,7 +260,6 @@ protected void waitForActionToComplete(Stage stage) throws StageException {
/**
* Check if we have the required permissions for nexus staging.
*
* @return
* @throws StageException if an exception occurred whilst checking the authorisation.
*/
public void checkAuthentication() throws StageException {
Expand Down Expand Up @@ -324,7 +324,6 @@ protected String getServerVersion() throws StageException {
/**
* Checks if this Nexus server uses asynchronous stage actions.
*
* @param version the version of this server
* @return true if this server uses asynchronous stage actions (i.e. the server is 2.4 or newer).
* @throws StageException if we could not retreive the server version.
*/
Expand Down Expand Up @@ -371,7 +370,7 @@ public List<Stage> getOpenStageIDs() throws StageException {
*
* @param doc the stagingRepositories to parse.
* @return a List of open stages.
* @throws XPathException if the XPath expression is invalid.
* @throws StageException if the XPath expression is invalid.
*/
protected List<Stage> getOpenStageIDs(Document doc) throws StageException {
List<Stage> stages = new ArrayList<Stage>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jvnet.hudson.plugins.m2release.pipeline;

import hudson.AbortException;
import hudson.Extension;
import hudson.model.Queue;
import hudson.model.queue.QueueListener;

/**
* copied from org.jenkinsci.plugins.workflow.support.steps.build.BuildQueueListener
*/
@Extension
public class M2ReleaseQueueListener extends QueueListener {
@Override
public void onLeft(Queue.LeftItem li) {
if(li.isCancelled()){
for (M2ReleaseTriggerAction.Trigger trigger : M2ReleaseTriggerAction.triggersFor(li)) {
trigger.context.onFailure(new AbortException("Build of " + li.task.getFullDisplayName() + " was cancelled"));
}
}
}


}
Loading