Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f58b220
Support JEP-200, enhance errors in management config page
Feb 21, 2019
a669a5b
fix WithSandbox
Mar 6, 2019
5ac28f1
add configurable timeout for setup and teardown
May 30, 2019
455b794
Cloudshell Jenkins plugin exception during long duration sandbox setu…
Aug 6, 2019
2f3ffbd
Product Backlog Item 172284:Jenkins plugin - Provide a way to get a s…
Aug 20, 2019
5713264
Bug 172532:Jenkins plugin - Setup timeout default value should be 300
Aug 27, 2019
c55135e
increment version before release
Aug 27, 2019
46d3231
change setupTimeout default, increment version 1.8.3
Aug 27, 2019
4bacba4
updated sandbox api
nahumtimerman Apr 27, 2022
319d0c6
updated sandbox api library
nahumtimerman Apr 27, 2022
21e5204
add repo explicitly
nahumtimerman Apr 27, 2022
ea1bebb
different repo to get maven-hpi-plugin pom.xml
nahumtimerman Apr 27, 2022
3cfa37f
...'
nahumtimerman Apr 27, 2022
3875a17
...
nahumtimerman Apr 27, 2022
69066b9
Merge pull request #8 from jenkinsci/nahum/ticket_50434_fix_for_login…
nahumtimerman Apr 27, 2022
7c0e175
snapshot
nahumtimerman Apr 27, 2022
77a50be
Merge pull request #9 from jenkinsci/nahum/ticket_50434_fix_for_login…
nahumtimerman Apr 27, 2022
dfe6779
...
nahumtimerman Apr 27, 2022
b7f2bb1
[maven-release-plugin] prepare release cloudshell-sandbox-1.8.4
nahumtimerman Apr 27, 2022
7f6b7af
_
nahumtimerman Apr 27, 2022
304127e
[maven-release-plugin] prepare release cloudshell-sandbox-1.8.4-alpha
nahumtimerman Apr 27, 2022
f7f53e1
[maven-release-plugin] prepare for next development iteration
nahumtimerman Apr 27, 2022
c4fd118
[maven-release-plugin] prepare release cloudshell-sandbox-1.8.5-alpha
nahumtimerman Apr 27, 2022
da71f7f
[maven-release-plugin] prepare for next development iteration
nahumtimerman Apr 27, 2022
839281c
update version
Jun 20, 2022
78bcaf1
[maven-release-plugin] prepare release cloudshell-sandbox-1.8.6
Jun 20, 2022
6ec5e6d
[maven-release-plugin] prepare for next development iteration
Jun 20, 2022
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
69,322 changes: 69,322 additions & 0 deletions debug.txt

Large diffs are not rendered by default.

64 changes: 53 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
</parent>

<artifactId>cloudshell-sandbox</artifactId>
<version>1.6.4-beta</version>
<version>1.8.7-SNAPSHOT</version>
<packaging>hpi</packaging>


<properties>
<jenkins.version>2.9</jenkins.version>
<java.level>7</java.level>
<java.level>8</java.level>
<jenkins-test-harness.version>2.2</jenkins-test-harness.version>
</properties>

Expand All @@ -24,10 +25,10 @@
<url>https://wiki.jenkins.io/display/JENKINS/CloudShell+Sandbox+Plugin</url>

<scm>
<connection>scm:git:git://github.com/jenkinsci/cloudshell-sandbox-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/cloudshell-sandbox-plugin.git</developerConnection>
<connection>scm:git:https://github.com/jenkinsci/cloudshell-sandbox-plugin.git</connection>
<developerConnection>scm:git:https://github.com/jenkinsci/cloudshell-sandbox-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/cloudshell-sandbox-plugin</url>
<tag>HEAD</tag>
<tag>cloudshell-sandbox-1.8.4</tag>
</scm>

<distributionManagement>
Expand Down Expand Up @@ -63,23 +64,31 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url> <!-- the https you've been looking for -->
<layout>default</layout>
<snapshots>
<enabled>false</enabled> <!-- or set to true if desired, default is false -->
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<dependencies>

<dependency>
<groupId>com.quali.cloudshell</groupId>
<artifactId>sandbox-api</artifactId>
<version>1.1.0.14</version>
<version>1.3.0.4</version>
</dependency>

<dependency>
Expand All @@ -94,6 +103,21 @@
<version>2.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>


<dependency>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
<version>1.0</version>
<type>signature</type>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mailer</artifactId>
Expand Down Expand Up @@ -147,8 +171,26 @@
<version>1.9</version>
<scope>test</scope>
</dependency>


</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<configuration>
<failOnError>${maven.findbugs.failure.strict}</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<disabledTestInjection>true</disabledTestInjection>
</configuration>
</plugin>
</plugins>
</build>

</project>
12 changes: 12 additions & 0 deletions release.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#release configuration
#Wed Apr 27 20:59:37 IDT 2022
scm.tagNameFormat=@{project.artifactId}-@{project.version}
pushChanges=true
scm.url=scm\:git\:https\://github.com/jenkinsci/cloudshell-sandbox-plugin.git
preparationGoals=clean install
remoteTagging=true
projectVersionPolicyId=default
scm.commentPrefix=[maven-release-plugin]
exec.additionalArguments=
exec.snapshotReleasePluginAllowed=false
completedPhase=check-poms
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,41 @@ public FormValidation doTestConnection(
return FormValidation.ok("Test completed successfully");
}

public FormValidation doCheckPw(@QueryParameter String value) {
if(value.isEmpty())
public FormValidation doCheckPw(@QueryParameter String value, @QueryParameter String serverAddress) {
if(serverAddress.isEmpty())
return FormValidation.ok();

if(value.isEmpty())
return FormValidation.errorWithMarkup("Password cannot be empty");
else
return FormValidation.ok();
}

public FormValidation doCheckUser(@QueryParameter String value) {
public FormValidation doCheckUser(@QueryParameter String value, @QueryParameter String serverAddress) {
if(serverAddress.isEmpty())
return FormValidation.ok();

if(value.isEmpty())
return FormValidation.errorWithMarkup("User cannot be empty");
else
return FormValidation.ok();
}

public FormValidation doCheckDomain(@QueryParameter String value) {
if(value.isEmpty())
public FormValidation doCheckDomain(@QueryParameter String value, @QueryParameter String serverAddress) {
if(serverAddress.isEmpty())
return FormValidation.ok();

if(value.isEmpty())
return FormValidation.errorWithMarkup("Domain cannot be empty");
else
return FormValidation.ok();
}


public FormValidation doCheckServerAddress(@QueryParameter String value) {
// String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
if(value.isEmpty())
return FormValidation.ok();

String regex = "^(https?)://[-a-zA-Z0-9-_.:]*[0-9]";
if(value.matches(regex))
return FormValidation.ok();
Expand All @@ -140,6 +151,7 @@ public FormValidation doCheckServerAddress(@QueryParameter String value) {
}



@Override
public String getDisplayName() {
return "CloudShell Build Step";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
package org.jenkinsci.plugins.cloudshell.builders;

import com.google.gson.Gson;
import com.quali.cloudshell.Constants;
import com.quali.cloudshell.QsServerDetails;
import com.quali.cloudshell.SandboxApiGateway;
import com.quali.cloudshell.qsExceptions.ExtendedSandboxApiException;
import hudson.Extension;
import hudson.Launcher;
import hudson.Util;
Expand All @@ -36,6 +38,7 @@ public class StartSandbox extends CloudShellBuildStep {
private final String blueprintName;
private final String sandboxDuration;
private final int maxWaitForSandboxAvailability;
private int setupTimeout;

@CheckForNull
private String sandboxDomain;
Expand All @@ -45,10 +48,11 @@ public class StartSandbox extends CloudShellBuildStep {
private String params;

@DataBoundConstructor
public StartSandbox(String blueprintName, String sandboxDuration, int maxWaitForSandboxAvailability) {
public StartSandbox(String blueprintName, String sandboxDuration, int maxWaitForSandboxAvailability, int setupTimeout) {
this.blueprintName = blueprintName;
this.sandboxDuration = sandboxDuration;
this.maxWaitForSandboxAvailability = maxWaitForSandboxAvailability;
this.setupTimeout = setupTimeout;
}

public String getBlueprintName() {
Expand All @@ -60,6 +64,9 @@ public String getSandboxDuration() {
public int getMaxWaitForSandboxAvailability() {
return maxWaitForSandboxAvailability;
}
public int getSetupTimeout() {
return setupTimeout;
}

@CheckForNull
public String getParams() {
Expand Down Expand Up @@ -98,17 +105,30 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
server = new QsServerDetails(server.serverAddress, server.user, server.pw, sandboxDomain, server.ignoreSSL);
}

SandboxApiGateway gateway = new SandboxApiGateway(new QsJenkinsTaskLogger(listener), server);
String sandboxId = gateway.TryStartBlueprint(blueprintName,
Integer.parseInt(sandboxDuration),
true,
(sandboxName == null || sandboxName.isEmpty()) ? null : sandboxName,
gateway.TryParseBlueprintParams(params),
maxWaitForSandboxAvailability);

Gson gson = new Gson();
String sandboxDetails = gson.toJson(gateway.GetSandboxDetails(sandboxId));
addSandboxToBuildActions(build, server, sandboxId, sandboxDetails);
int customSetupTimeout =0;
if (setupTimeout == 0)
customSetupTimeout = Constants.CONNECT_TIMEOUT_SECONDS;
else
customSetupTimeout= setupTimeout*60;

SandboxApiGateway gateway = new SandboxApiGateway(new QsJenkinsTaskLogger(listener), server, customSetupTimeout);
String sandboxId = "";
try {
sandboxId = gateway.TryStartBlueprint(blueprintName,
Integer.parseInt(sandboxDuration),
true,
(sandboxName == null || sandboxName.isEmpty()) ? null : sandboxName,
gateway.TryParseBlueprintParams(params),
maxWaitForSandboxAvailability);
Gson gson = new Gson();
String sandboxDetails = gson.toJson(gateway.GetSandboxDetails(sandboxId));
addSandboxToBuildActions(build, server, sandboxId, sandboxDetails);
}
catch (ExtendedSandboxApiException e)
{
addSandboxToBuildActions(build, server, e.getSandboxId(), "");
throw e;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
import java.util.Arrays;
import java.util.List;

/**
* Post-build step that allow stop all matched container
*
* @author magnayn
*/
public class CloudShellPublisherControl extends Recorder implements Serializable {

@DataBoundConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ public class SandboxStartStep extends AbstractStepImpl {
@CheckForNull
private String params;

private int setupTimeout;

@DataBoundConstructor
public SandboxStartStep(@Nonnull String name, int duration, int timeout) {
this.name = name;
this.duration = duration;
this.timeout = timeout;
}


@CheckForNull
public String getParams() {
return params;
Expand All @@ -55,6 +56,15 @@ public void setSandboxName(@CheckForNull String sandboxName) {
this.sandboxName = Util.fixNull(sandboxName);
}

public int getSetupTimeout() {
return setupTimeout;
}

@DataBoundSetter
public void setSetupTimeout( int setupTimeout) {
this.setupTimeout = setupTimeout;
}

@CheckForNull
public String getSandboxDomain() {
return sandboxDomain;
Expand Down Expand Up @@ -91,7 +101,7 @@ public static class SandboxStartStepExecution extends AbstractSynchronousStepExe
@Override
protected String run() throws Exception {
StepsCommon stepsCommon = new StepsCommon();
return stepsCommon.startSandbox(listener, step.name, step.duration ,step.params, step.sandboxName, step.timeout, step.sandboxDomain);
return stepsCommon.startSandbox(listener, step.name, step.duration ,step.params, step.sandboxName, step.timeout, step.sandboxDomain, step.setupTimeout*60);
}

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
package org.jenkinsci.plugins.cloudshell.steps;

import com.google.inject.Inject;
import com.quali.cloudshell.Constants;
import com.quali.cloudshell.qsExceptions.SandboxApiException;
import hudson.EnvVars;
import hudson.Extension;
import hudson.model.TaskListener;
import jnr.constants.Constant;
import net.sf.json.JSONObject;
import org.jenkinsci.plugins.workflow.steps.*;
import org.kohsuke.stapler.DataBoundConstructor;
Expand All @@ -53,7 +55,7 @@ public class SandboxStep extends AbstractStepImpl {

@Deprecated
@DataBoundConstructor
public SandboxStep(@Nonnull String name, int maxDuration, String params, String sandboxName, String sandboxDomain, int timeout) {
public SandboxStep(@Nonnull String name, int maxDuration, String params, String sandboxName, String sandboxDomain, int timeout) {
this.name = name;
this.maxDuration = maxDuration;
this.params = params;
Expand Down Expand Up @@ -99,7 +101,7 @@ public void stop(@Nonnull Throwable throwable) throws Exception {
listener.getLogger().println("Aborting CloudShell Sandbox!");
if (sandboxId != null && !sandboxId.isEmpty())
{
new StepsCommon().stopSandbox(listener, sandboxId, getContext());
new StepsCommon().stopSandbox(listener, sandboxId, getContext(), Constants.CONNECT_TIMEOUT_SECONDS);
}
}

Expand All @@ -110,7 +112,7 @@ private boolean CreateSandbox(StepsCommon stepsCommon) throws
KeyManagementException,
IOException, InterruptedException {

sandboxId = stepsCommon.startSandbox(listener, step.name, step.maxDuration, step.params, step.sandboxName, step.timeout);
sandboxId = stepsCommon.startSandbox(listener, step.name, step.maxDuration, step.params, step.sandboxName, step.timeout, step.sandboxDomain, Constants.CONNECT_TIMEOUT_SECONDS);
return false;
}

Expand All @@ -127,7 +129,7 @@ private static class Callback extends BodyExecutionCallback {

private void stopSandbox(StepContext context) {
StepsCommon stepsCommon = new StepsCommon();
stepsCommon.stopSandbox(listener, sandboxId, context);
stepsCommon.stopSandbox(listener, sandboxId, context, Constants.CONNECT_TIMEOUT_SECONDS);
}

@Override
Expand Down Expand Up @@ -192,6 +194,5 @@ public Step newInstance(StaplerRequest req, JSONObject formData) throws FormExce
String sandboxDomain = formData.getString("sandboxDomain");
return new SandboxStep(name, duration, params, sandboxName, sandboxDomain, timeout);
}

}
}
Loading