Skip to content

Commit

Permalink
Added support in CSH for private SSH source files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tal Yanai committed Sep 29, 2020
1 parent 7fe822e commit 7b89a83
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 10 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ the following format within the job working directory: 

## Change Log

##### Version 3.0.6 (Sep 29, 2020)

- Added support in CSH scripts for sourcing using Linux Users. 
- Fixed a bug to support private SSH without selecting any other login method in addition.

##### Version 3.0.5 (Aug 24, 2020)

- Remove description from the tables tooltip at the dashboard and vManager Job Overview. 
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jenkinsci/plugins/vmanager/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ public HttpURLConnection getVAPIConnection(String apiUrl, boolean requireAuth, S
}

public String executeVSIFLaunch(String[] vsifs, String url, boolean requireAuth, String user, String password, TaskListener listener, boolean dynamicUserId, String buildID, int buildNumber,
String workPlacePath, int connConnTimeOut, int connReadTimeout, boolean advConfig, String jsonEnvInput, boolean useUserOnFarm, String userFarmType, String[] farmUserPassword, StepHolder stepHolder, String envSourceInputFile, String workingJobDir, VMGRBuildArchiver vMGRBuildArchiver, boolean userPrivateSSHKey, String jsonAttrValuesInput, String executionType, String[] sessionNames) throws Exception {
String workPlacePath, int connConnTimeOut, int connReadTimeout, boolean advConfig, String jsonEnvInput, boolean useUserOnFarm, String userFarmType, String[] farmUserPassword, StepHolder stepHolder, String envSourceInputFile, String workingJobDir, VMGRBuildArchiver vMGRBuildArchiver, boolean userPrivateSSHKey, String jsonAttrValuesInput, String executionType, String[] sessionNames, String envSourceInputFileType) throws Exception {

boolean notInTestMode = true;
if (listener == null) {
Expand Down Expand Up @@ -846,7 +846,7 @@ public String executeVSIFLaunch(String[] vsifs, String url, boolean requireAuth,
reader.close();
}
}
} else {
} else if (!userPrivateSSHKey) {
userFarm = farmUserPassword[0];;
passwordFarm = farmUserPassword[1];;
}
Expand All @@ -858,7 +858,7 @@ public String executeVSIFLaunch(String[] vsifs, String url, boolean requireAuth,
}

if ((envSourceInputFile != null) && (!"".equals(envSourceInputFile.trim()))) {
String scriptShell = "BSH";
String scriptShell = envSourceInputFileType;
input = input + ",\"preliminaryStage\":{\"sourceFilePath\":\"" + envSourceInputFile + "\",\"shell\":\"" + scriptShell + "\"}";
}

Expand Down
20 changes: 18 additions & 2 deletions src/main/java/org/jenkinsci/plugins/vmanager/VMGRLaunch.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class VMGRLaunch extends Builder {
private final String attrValuesFile;

private final String inaccessibleResolver;
private final String envSourceInputFileType;
private final String stoppedResolver;
private final String failedResolver;
private final String doneResolver;
Expand Down Expand Up @@ -110,7 +111,7 @@ public VMGRLaunch(String vAPIUrl, String vAPIUser, String vAPIPassword, String v
boolean dynamicUserId, boolean advConfig, int connTimeout, int readTimeout, boolean envVarible, String envVaribleFile, String inaccessibleResolver, String stoppedResolver, String failedResolver, String doneResolver, String suspendedResolver, boolean waitTillSessionEnds,
int stepSessionTimeout, boolean generateJUnitXML, boolean extraAttributesForFailures, String staticAttributeList, boolean markBuildAsFailedIfAllRunFailed, boolean failJobIfAllRunFailed, String envSourceInputFile, boolean vMGRBuildArchive, boolean deleteAlsoSessionDirectory,
boolean genericCredentialForSessionDelete, String archiveUser, String archivePassword, String famMode, String famModeLocation, boolean noAppendSeed, boolean markBuildAsPassedIfAllRunPassed, boolean failJobUnlessAllRunPassed, boolean userPrivateSSHKey, boolean attrValues,
String attrValuesFile, String executionType, String sessionsInputFile, boolean deleteSessionInputFile, boolean noneSharedNFS, String envVariableType, String envVariableText, String attrVariableType, String attrVariableText, boolean pauseSessionOnBuildInterruption) {
String attrValuesFile, String executionType, String sessionsInputFile, boolean deleteSessionInputFile, boolean noneSharedNFS, String envVariableType, String envVariableText, String attrVariableType, String attrVariableText, boolean pauseSessionOnBuildInterruption, String envSourceInputFileType) {
this.vAPIUrl = vAPIUrl;
this.vAPIUser = vAPIUser;
this.vAPIPassword = vAPIPassword;
Expand All @@ -134,6 +135,7 @@ public VMGRLaunch(String vAPIUrl, String vAPIUser, String vAPIPassword, String v
this.connTimeout = connTimeout;
this.readTimeout = readTimeout;

this.envSourceInputFileType = envSourceInputFileType;
this.inaccessibleResolver = inaccessibleResolver;
this.stoppedResolver = stoppedResolver;
this.failedResolver = failedResolver;
Expand Down Expand Up @@ -339,6 +341,9 @@ public int getStepSessionTimeout() {
public String getInaccessibleResolver() {
return inaccessibleResolver;
}
public String getEnvSourceInputFileType(){
return envSourceInputFileType;
}

public String getStoppedResolver() {
return stoppedResolver;
Expand Down Expand Up @@ -478,6 +483,8 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
envSourceInputFileFix = envSourceInputFile;
}
listener.getLogger().println("The User's source file is: " + envSourceInputFileFix);
listener.getLogger().println("The User's source file type is: " + envSourceInputFileType);

} else {
listener.getLogger().println("The User's source file wasn't set");
}
Expand Down Expand Up @@ -694,7 +701,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis


String output = utils.executeVSIFLaunch(vsifFileNames, vAPIUrl, authRequired, tempUser, tempPassword, listener, dynamicUserId, build.getId(), build.getNumber(),
"" + build.getWorkspace(), connTimeout, readTimeout, advConfig, jsonEnvInput, useUserOnFarm, userFarmType, farmUserPassword, stepHolder, envSourceInputFileFix, workingJobDir, vMGRBuildArchiver, userPrivateSSHKey, jsonAttrValuesInput, executionType, sessionNames);
"" + build.getWorkspace(), connTimeout, readTimeout, advConfig, jsonEnvInput, useUserOnFarm, userFarmType, farmUserPassword, stepHolder, envSourceInputFileFix, workingJobDir, vMGRBuildArchiver, userPrivateSSHKey, jsonAttrValuesInput, executionType, sessionNames,envSourceInputFileType);
if (!"success".equals(output)) {
listener.getLogger().println("Failed to launch vsifs for build " + build.getId() + " " + build.getNumber() + "\n");
listener.getLogger().println(output + "\n");
Expand Down Expand Up @@ -842,6 +849,15 @@ public ListBoxModel doFillInaccessibleResolverItems() {
items.add("Ignore, and continue to wait", "ignore");
return items;
}

public ListBoxModel doFillEnvSourceInputFileTypeItems() {
ListBoxModel items = new ListBoxModel();
items.add("bash", "BSH");
items.add("csh", "CSH");
return items;
}



public ListBoxModel doFillStoppedResolverItems() {
ListBoxModel items = new ListBoxModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class VMGRLaunchStep extends Step {
private final boolean pipelineNodes;
private final String masterWorkspaceLocation;

private final String envSourceInputFileType;
private final String inaccessibleResolver;
private final String stoppedResolver;
private final String failedResolver;
Expand Down Expand Up @@ -96,7 +97,7 @@ public VMGRLaunchStep(String vAPIUrl, String vAPIUser, String vAPIPassword, Stri
boolean dynamicUserId, boolean advConfig, int connTimeout, int readTimeout, boolean envVarible, String envVaribleFile, String inaccessibleResolver, String stoppedResolver, String failedResolver, String doneResolver, String suspendedResolver, boolean waitTillSessionEnds, int stepSessionTimeout,
boolean generateJUnitXML, boolean extraAttributesForFailures, String staticAttributeList, boolean markBuildAsFailedIfAllRunFailed, boolean failJobIfAllRunFailed, String envSourceInputFile, boolean vMGRBuildArchive, boolean deleteAlsoSessionDirectory, boolean genericCredentialForSessionDelete,
String archiveUser, String archivePassword, String famMode, String famModeLocation, boolean noAppendSeed, boolean pipelineNodes, String masterWorkspaceLocation, boolean markBuildAsPassedIfAllRunPassed, boolean failJobUnlessAllRunPassed, boolean userPrivateSSHKey, boolean attrValues,
String attrValuesFile, String executionType, String sessionsInputFile, boolean deleteSessionInputFile, boolean pauseSessionOnBuildInterruption) {
String attrValuesFile, String executionType, String sessionsInputFile, boolean deleteSessionInputFile, boolean pauseSessionOnBuildInterruption, String envSourceInputFileType) {
this.vAPIUrl = vAPIUrl;
this.vAPIUser = vAPIUser;
this.vAPIPassword = vAPIPassword;
Expand All @@ -122,6 +123,7 @@ public VMGRLaunchStep(String vAPIUrl, String vAPIUser, String vAPIPassword, Stri
this.connTimeout = connTimeout;
this.readTimeout = readTimeout;

this.envSourceInputFileType = envSourceInputFileType;
this.inaccessibleResolver = inaccessibleResolver;
this.stoppedResolver = stoppedResolver;
this.failedResolver = failedResolver;
Expand Down Expand Up @@ -316,6 +318,10 @@ public int getStepSessionTimeout() {
public String getInaccessibleResolver() {
return inaccessibleResolver;
}

public String getEnvSourceInputFileType(){
return envSourceInputFileType;
}

public String getStoppedResolver() {
return stoppedResolver;
Expand Down Expand Up @@ -469,6 +475,15 @@ public ListBoxModel doFillInaccessibleResolverItems() {
items.add("Ignore, and continue to wait", "ignore");
return items;
}

public ListBoxModel doFillEnvSourceInputFileTypeItems() {
ListBoxModel items = new ListBoxModel();
items.add("bash", "BSH");
items.add("csh", "CSH");
return items;
}



public ListBoxModel doFillStoppedResolverItems() {
ListBoxModel items = new ListBoxModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ protected Void run() throws Exception {
}
if (step.getEnvSourceInputFile() != null && !"".equals(step.getEnvSourceInputFile().trim())) {
listener.getLogger().println("The User's source file is: " + step.getEnvSourceInputFile());
listener.getLogger().println("The User's source file type is: " + step.getEnvSourceInputFileType());

} else {
listener.getLogger().println("The User's source file wasn't set");
}
Expand Down Expand Up @@ -257,7 +259,7 @@ protected Void run() throws Exception {


String output = utils.executeVSIFLaunch(vsifFileNames, step.getVAPIUrl(), step.isAuthRequired(), tempUser, tempPassword, listener, step.isDynamicUserId(), buildId, buildNumber,
"" + workspace, step.getConnTimeout(), step.getReadTimeout(), step.isAdvConfig(), jsonEnvInput, step.isUseUserOnFarm(), step.getUserFarmType(), farmUserPassword, stepHolder, step.getEnvSourceInputFile(), workingJobDir, vMGRBuildArchiver, step.isUserPrivateSSHKey(), jsonAttrValuesInput, step.getExecutionType(), sessionNames);
"" + workspace, step.getConnTimeout(), step.getReadTimeout(), step.isAdvConfig(), jsonEnvInput, step.isUseUserOnFarm(), step.getUserFarmType(), farmUserPassword, stepHolder, step.getEnvSourceInputFile(), workingJobDir, vMGRBuildArchiver, step.isUserPrivateSSHKey(), jsonAttrValuesInput, step.getExecutionType(), sessionNames, step.getEnvSourceInputFileType());
if (!"success".equals(output)) {
listener.getLogger().println("Failed to launch vsifs for build " + buildId + " " + buildNumber + "\n");
listener.getLogger().println(output + "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
<f:entry title="Name of credential file" field="credentialInputFile" description="Name of input file with credential values (not mandatory)"><f:textbox /></f:entry>
<f:entry title="Delete Credential File" field="deleteCredentialInputFile" description="If checked, the job will delete the credential file name after processing it."><f:checkbox name="deleteCredentialInputFile" checked="${it.deleteCredentialInputFile}"/></f:entry>
</f:radioBlock>
<f:entry title="User Pre Exceution File" field="envSourceInputFile" description="Path to user env params declaration for sourcing prior to execution (not mandatory) - vManager 17.10 and above only"><f:textbox /></f:entry>
<f:entry title="User Pre Exceution File" field="envSourceInputFile" description="Path to user env params declaration for sourcing prior to execution (not mandatory) - vManager 17.10 and above only"><f:textbox /></f:entry>
<f:entry title="User Pre Exceution File Type" field="envSourceInputFileType" ><f:select /></f:entry>
</f:optionalBlock>
</table>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</br>
Relative path is also supported (aka ~/doSomething.sh).
</br>
Script must be in bash.
Script must be in bash or csh.
</br></br>
The file should be place into a directory with a read permission for the user who launches the regression.</br>
In case this field is empty, this field is ignored</br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<f:entry title="Delete Credential File" field="deleteCredentialInputFile" description="If checked, the job will delete the credential file name after processing it."><f:checkbox name="deleteCredentialInputFile" checked="${it.deleteCredentialInputFile}"/></f:entry>
</f:radioBlock>
<f:entry title="User Pre Exceution File" field="envSourceInputFile" description="Path to user env params declaration for sourcing prior to execution (not mandatory) - vManager 17.10 and above only"><f:textbox /></f:entry>
<f:entry title="User Pre Exceution File Type" field="envSourceInputFileType" ><f:select /></f:entry>
</f:optionalBlock>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</br>
Relative path is also supported (aka ~/doSomething.sh).
</br>
Script must be in bash.
Script must be in bash or csh.
</br></br>
The file should be place into a directory with a read permission for the user who launches the regression.</br>
In case this field is empty, this field is ignored</br>
Expand Down

0 comments on commit 7b89a83

Please sign in to comment.