Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38ef0b5
commit d0c59e9
Showing
12 changed files
with
369 additions
and
20 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions
95
src/main/java/de/tracetronic/jenkins/plugins/ecutest/tool/LicenseETBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright (c) 2015-2020 TraceTronic GmbH | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
package de.tracetronic.jenkins.plugins.ecutest.tool; | ||
|
||
import de.tracetronic.jenkins.plugins.ecutest.ETPluginException; | ||
import de.tracetronic.jenkins.plugins.ecutest.log.TTConsoleLogger; | ||
import de.tracetronic.jenkins.plugins.ecutest.tool.client.ETClient; | ||
import de.tracetronic.jenkins.plugins.ecutest.tool.installation.ETInstallation; | ||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.FilePath; | ||
import hudson.Launcher; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
import org.jenkinsci.Symbol; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* Builder providing the license check of ECU-TEST. | ||
*/ | ||
public class LicenseETBuilder extends AbstractToolBuilder { | ||
|
||
/** | ||
* Instantiates a new {@link LicenseETBuilder}. | ||
* | ||
* @param toolName the tool name identifying the {@link ETInstallation} to be used | ||
*/ | ||
@DataBoundConstructor | ||
public LicenseETBuilder(@Nonnull final String toolName) { | ||
super(toolName); | ||
} | ||
|
||
@Override | ||
public int getDefaultTimeout() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void performTool(final Run<?, ?> run, final FilePath workspace, final Launcher launcher, | ||
final TaskListener listener) throws InterruptedException, IOException, ETPluginException { | ||
// Check running instance | ||
final List<String> foundProcesses = ETClient.checkProcesses(launcher, listener, false); | ||
if (!foundProcesses.isEmpty()) { | ||
final TTConsoleLogger logger = new TTConsoleLogger(listener); | ||
logger.logInfo("Running ECU-TEST instance found, therefore a license is available..."); | ||
} else { | ||
// Verify selected ECU-TEST installation | ||
final EnvVars envVars = run.getEnvironment(listener); | ||
// Verify selected ECU-TEST installation | ||
if (!isInstallationVerified(envVars)) { | ||
setInstallation(configureToolInstallation(workspace.toComputer(), listener, envVars)); | ||
} | ||
|
||
// Check license of ECU-TEST | ||
final String installPath = getInstallation().getExecutable(launcher); | ||
final String toolName = getInstallation().getName(); | ||
final ETClient etClient = new ETClient(toolName, installPath, "", "", getDefaultTimeout(), false); | ||
etClient.setLicenseCheck(true); | ||
final TTConsoleLogger logger = new TTConsoleLogger(listener); | ||
|
||
if (!etClient.checkLicense(launcher, listener)) { | ||
logger.logError(String.format("-> No valid license for '%s' found.", toolName)); | ||
throw new ETPluginException(String.format("License check '%s' failed.", toolName)); | ||
} else { | ||
logger.logInfo(String.format("-> Valid license for '%s' found.", toolName)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* DescriptorImpl for {@link LicenseETBuilder}. | ||
*/ | ||
@Symbol("checkETLicense") | ||
@Extension(ordinal = 10012) | ||
public static final class DescriptorImpl extends AbstractToolDescriptor { | ||
|
||
@Override | ||
public int getDefaultTimeout() { | ||
return 0; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getDisplayName() { | ||
return Messages.LicenseETBuilder_DisplayName(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/resources/de/tracetronic/jenkins/plugins/ecutest/tool/LicenseETBuilder/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- | ||
Copyright (c) 2015-2020 TraceTronic GmbH | ||
SPDX-License-Identifier: BSD-3-Clause | ||
--> | ||
|
||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form"> | ||
<st:include class="de.tracetronic.jenkins.plugins.ecutest.tool.installation.ETInstallation" page="select.jelly"/> | ||
</j:jelly> |
24 changes: 24 additions & 0 deletions
24
src/main/resources/de/tracetronic/jenkins/plugins/ecutest/tool/LicenseETBuilder/help.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
Copyright (c) 2015-2020 TraceTronic GmbH | ||
SPDX-License-Identifier: BSD-3-Clause | ||
--> | ||
|
||
<div> | ||
<p>Check ECU-TEST license.</p> | ||
<strong>Pipelines usage:</strong> | ||
<dl>Signatures: | ||
<dd> | ||
<pre> | ||
checkETLicense(String toolName) : void | ||
</pre> | ||
</dd> | ||
</dl> | ||
<dl>Examples: | ||
<dd> | ||
<pre> | ||
checkETLicense('ECU-TEST') | ||
</pre> | ||
</dd> | ||
</dl> | ||
</div> |
24 changes: 24 additions & 0 deletions
24
src/main/resources/de/tracetronic/jenkins/plugins/ecutest/tool/LicenseETBuilder/help_de.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
Copyright (c) 2015-2020 TraceTronic GmbH | ||
SPDX-License-Identifier: BSD-3-Clause | ||
--> | ||
|
||
<div> | ||
<p>Lizenzüberprüfung von ECU-TEST.</p> | ||
<strong>Verwendung in Pipelines:</strong> | ||
<dl>Signaturen: | ||
<dd> | ||
<pre> | ||
checkETLicense(String toolName) : void | ||
</pre> | ||
</dd> | ||
</dl> | ||
<dl>Beispiele: | ||
<dd> | ||
<pre> | ||
checkETLicense('ECU-TEST') | ||
</pre> | ||
</dd> | ||
</dl> | ||
</div> |
3 changes: 2 additions & 1 deletion
3
src/main/resources/de/tracetronic/jenkins/plugins/ecutest/tool/Messages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
src/main/resources/de/tracetronic/jenkins/plugins/ecutest/tool/Messages_de.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.