Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hummerstudio committed May 1, 2020
0 parents commit fb115ce
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 0 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buildPlugin(configurations: buildPlugin.recommendedConfigurations())
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Tang Ming

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Pipeline Keep Running Step Plugin

## Introduction

This plugin provides `keepRunning` step to keep the process running even if the build has finished.

## Example

```
keepRunning {
sh '/usr/local/apache-tomact/bin/startup.sh
}
```
111 changes: 111 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.4</version>
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
<artifactId>pipeline-keep-running-step</artifactId>
<version>1.0</version>
<packaging>hpi</packaging>
<properties>
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
<jenkins.version>2.121.2</jenkins.version>
<java.level>8</java.level>
</properties>
<name>Pipeline Keep Running Step</name>
<description>
This plugin provides keepRunning step to keep the process running even if the build has finished.
</description>
<url>https://github.com/jenkinsci/pipeline-keep-running-step-plugin</url>
<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.39</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.11.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.14</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.19</version>
</dependency>
</dependencies>

<developers>
<developer>
<id>hummerstudio</id>
<name>Tang Ming</name>
<url>https://shanyshanb.com</url>
<email>hummerstudio@163.com</email>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/jenkinsci/pipeline-keep-running-step-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/pipeline-keep-running-step-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/pipeline-keep-running-step-plugin</url>
</scm>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Tang Ming
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.shanyshanb.plugins.pipeline.steps;

import com.google.common.collect.ImmutableSet;
import hudson.Extension;
import hudson.FilePath;
import hudson.model.TaskListener;
import net.sf.json.JSON;
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.Nonnull;
import java.util.Set;

/**
* Keep the process running even if the build has finished.
*
* @author Tang Ming
*/
public class KeepRunningStep extends Step {


@DataBoundConstructor
public KeepRunningStep() {

}

@Override
public StepExecution start(StepContext context) {
return new KeepRunningStepExecution(context);
}

@Extension
public static class DescriptorImpl extends StepDescriptor {
public DescriptorImpl() {
}

@Override
public Set<? extends Class<?>> getRequiredContext() {
return ImmutableSet.of(TaskListener.class, FilePath.class);
}

@Override
public boolean takesImplicitBlockArgument() {
return true;
}

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

@Override
@Nonnull
public String getDisplayName() {
return Messages.KeepRunningStep_DescriptorImpl_displayName();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Tang Ming
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.shanyshanb.plugins.pipeline.steps;

import org.jenkinsci.plugins.workflow.steps.*;

import javax.annotation.Nonnull;
import java.util.HashMap;
import java.util.Map;

/**
* Execution of {@link KeepRunningStep}.
*
* @author Tang Ming
*/
public class KeepRunningStepExecution extends AbstractStepExecutionImpl {
private static final long serialVersionUID = 1L;

protected KeepRunningStepExecution(@Nonnull StepContext context) {
super(context);
}

@Override
public boolean start() throws Exception {
Map<String, String> keepRunning = new HashMap<>();
keepRunning.put("JENKINS_NODE_COOKIE", "keepRunning");
getContext().newBodyInvoker().
withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), EnvironmentExpander.constant(keepRunning))).
withCallback(BodyExecutionCallback.wrap(getContext())).
start();
return false;
}

@Override public void onResume() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:block>
<p>This is a special step. No snippet generation available. See inline help for more information.</p>
</f:block>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p>
Keep the process running even if the build has finished.
</p>
<p>
<strong>Example:</strong><br/>
<code><pre>
keepRunning {
sh '/usr/local/apache-tomact/bin/startup.sh
}
</pre></code>
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KeepRunningStep_DescriptorImpl_displayName=Keep the process running even if the build has finished.
4 changes: 4 additions & 0 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
This plugin provides keepRunning step to keep the process running even if the build has finished.
</div>

0 comments on commit fb115ce

Please sign in to comment.