Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
33 changes: 24 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
plugins {
id "com.github.hierynomus.license" version "0.13.0"
id "com.github.hierynomus.license" version "0.16.1"
id "com.xebialabs.xl.docker" version "1.0.0"
}

version = '2.0.0'
version = '3.0.0'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.ADOPTIUM
}
}

xlDocker {
compileImage = 'xebialabs/xlr_dev_compile'
Expand All @@ -18,21 +25,29 @@ xlDocker {
runPortMapping = '15516:5516'
}

def apiVersion = '2017.1.0'
def apiVersion = '2019.3.13'

dependencies {
compile "com.xebialabs.deployit:udm-plugin-api:$apiVersion"
compile "com.xebialabs.overthere:overthere:2.4.4"
compile "com.xebialabs.xlrelease.plugins:xlr-remotescript-plugin:5.0.1"
implementation "com.xebialabs.deployit:udm-plugin-api:$apiVersion"
implementation "com.xebialabs.overthere:overthere:5.6.16"
implementation "com.xebialabs.xlrelease.plugins:xlr-remotescript-plugin:24.3.7"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @RolandasJas Can you please update the remote script version to the new MR version format - 24.3.7-512.938

}

repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://dist.xebialabs.com/public/maven2'
url 'https://dist.xebialabs.com/public/maven2'
}
["releases", "public", "thirdparty"].each { r ->
maven {
credentials {
username nexusUserName
password nexusPassword
}
url "${nexusBaseUrl}/repositories/${r}"
}
Comment on lines +42 to +49
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need private repo if we compile against xlr-remotescript-plugin?
isn't that plugin published to public repo? (if not maybe we should ask infra to publish it there?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The xlr-remotescript-plugin plugin only contains its files, it does not contain the release code, that comes as a transitive dependency, which you can't build.

}
maven { url "http://repo.maven.apache.org/maven2" }
}


Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -6,91 +6,45 @@

package com.xebialabs.xlrelease.plugin.overthere;

import com.xebialabs.deployit.plugin.api.udm.ConfigurationItem;
import com.xebialabs.overthere.*;
import com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler;
import com.xebialabs.overthere.util.OverthereUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.xebialabs.xlrelease.domain.PythonScript;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;

import static com.xebialabs.overthere.ConnectionOptions.*;
import static com.xebialabs.overthere.OperatingSystemFamily.UNIX;
import static com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler.capturingHandler;
import static java.nio.charset.StandardCharsets.UTF_8;

public class PowershellScript extends RemoteScript {
private static final String SCRIPT_NAME = "uploaded-script";

private final ConnectionOptions options = new ConnectionOptions();
private final String protocol;
private final String remotePath;
private final String powerShellPath;
private final String script;
private final String extension;
private final String errorActionPreference;
private final String warningPreference;

private final CapturingOverthereExecutionOutputHandler stdout = capturingHandler();
private final CapturingOverthereExecutionOutputHandler stderr = capturingHandler();

public PowershellScript(ConfigurationItem remoteScript) {
super( remoteScript );
this.protocol = remoteScript.getProperty("protocol");
copyPropertiesToConnectionOptions(options, remoteScript);
public PowershellScript(PythonScript remoteScript) {
super(remoteScript);

this.script = remoteScript.getProperty("script");
this.extension = options.get(OPERATING_SYSTEM, UNIX).getScriptExtension();
this.remotePath = remoteScript.getProperty("remotePath");
this.powerShellPath = remoteScript.getProperty("powerShellPath");
this.errorActionPreference = remoteScript.getProperty("errorActionPreference");
this.warningPreference = remoteScript.getProperty("warningPreference");
}

public int execute() {
try (OverthereConnection connection = Overthere.getConnection(protocol, options)) {
connection.setWorkingDirectory(connection.getFile(remotePath));

// Upload and execute the script
//OverthereFile targetFile = connection.getTempFile(SCRIPT_NAME, extension);
OverthereFile targetFile = connection.getTempFile(SCRIPT_NAME, ".ps1");
OverthereUtils.write(script.getBytes(UTF_8), targetFile);
targetFile.setExecutable(true);

CmdLine scriptCommand = CmdLine.build( this.powerShellPath, "-ExecutionPolicy", "Unrestricted", "-Inputformat", "None", "-NonInteractive", "-NoProfile", "-Command", "$ErrorActionPreference = '" + this.errorActionPreference + "'; $WarningPreference = '" + this.warningPreference + "';& " + targetFile.getPath() + "; if($LastExitCode) { Exit $LastExitCode; }" );

return connection.execute(stdout, stderr, scriptCommand);
} catch (Exception e) {
StringWriter stacktrace = new StringWriter();
PrintWriter writer = new PrintWriter(stacktrace, true);
e.printStackTrace(writer);
stderr.handleLine(stacktrace.toString());

return 1;
@Override
public int doExecute(OverthereConnection connection, OutputHandler stdoutHandler, OutputHandler stderrHandler) {
if (this.remotePath != null && !this.remotePath.isEmpty()) {
connection.setWorkingDirectory(connection.getFile(this.remotePath));
}

}
OverthereFile targetFile = connection.getTempFile(SCRIPT_NAME, ".ps1");
OverthereUtils.write(script.getBytes(UTF_8), targetFile);
targetFile.setExecutable(true);

public String getStdout() {
return stdout.getOutput();
}
CmdLine scriptCommand = CmdLine.build(this.powerShellPath, "-ExecutionPolicy", "Unrestricted", "-Inputformat", "None", "-NonInteractive", "-NoProfile", "-Command", "$ErrorActionPreference = '" + this.errorActionPreference + "'; $WarningPreference = '" + this.warningPreference + "';& " + targetFile.getPath() + "; if($LastExitCode) { Exit $LastExitCode; }");

public List<String> getStdoutLines() {
return stdout.getOutputLines();
return connection.execute(stdoutHandler, stderrHandler, scriptCommand);
}

public String getStderr() {
return stderr.getOutput();
}

public List<String> getStderrLines() {
return stderr.getOutputLines();
}

private static Logger logger = LoggerFactory.getLogger(RemoteScript.class);

}