Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit e497f57

Browse files
authored
Merge pull request #401 from mathworks/2.16.0-SNAPSHOT-Qualification
Merge 2.16.0 snapshot qualification to dev_main
2 parents bc36eed + 23097aa commit e497f57

File tree

9 files changed

+271
-162
lines changed

9 files changed

+271
-162
lines changed

CONFIGDOC.md

Lines changed: 200 additions & 76 deletions
Large diffs are not rendered by default.

examples/Run-MATLAB-Tests.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,46 @@ To follow the steps in this example:
1818

1919
* MATLAB and the plugin for MATLAB must be installed on your Jenkins server. For information on how to install a plugin in Jenkins, see [Managing Plugins](https://jenkins.io/doc/book/managing/plugins/).
2020
* The Times Table App project must be under source control. For example, you can create a new repository for the project using your GitHub® account. For more information, see [Use Source Control with Projects](https://www.mathworks.com/help/matlab/matlab_prog/use-source-control-with-projects.html).
21-
* The [Cobertura](https://plugins.jenkins.io/cobertura) and [JUnit](https://plugins.jenkins.io/junit) plugins must be installed. These plugins are required to publish the artifacts using post-build actions.
21+
* The [coverage](https://plugins.jenkins.io/coverage/) and [JUnit](https://plugins.jenkins.io/junit) plugins must be installed. These plugins are required to publish the artifacts using post-build actions.
2222

2323
## Create a Freestyle Project to Run MATLAB Tests
2424
Create a new project and configure it by following these steps:
2525
1. In your Jenkins interface, select **New Item** on the left. A new page opens where you can choose the type of your project. Enter a project name, and then click **Freestyle project**. To confirm your choices, click **OK**.
2626

27-
![create_project](https://github.com/mathworks/jenkins-matlab-plugin/assets/48831250/8aa314b3-60fc-4534-bd49-223617ca0542)
27+
![create_project](https://github.com/user-attachments/assets/cedd846b-4460-43d7-9278-253c7ee7260e)
2828

2929
2. On the project configuration page, in the **Source Code Management** section, specify the repository that hosts your tests.
3030

31-
![source_control](https://github.com/mathworks/jenkins-matlab-plugin/assets/48831250/5befa3c5-6924-4abb-bc34-25ff3328ee47)
31+
![source_control](https://github.com/user-attachments/assets/3b888ed9-b521-4c3c-a932-ad5f9de563c3)
3232

33-
3. In the **Build Environment** section, select **Use MATLAB version** and specify the MATLAB version you want to use in the build. If your preferred MATLAB version is not listed under **Use MATLAB version**, enter the full path to its root folder in the **MATLAB root** box.
33+
3. In the **Environment** section, select **Use MATLAB version** and specify the MATLAB version you want to use in the build. If your preferred MATLAB version is not listed under **Use MATLAB version**, enter the full path to its root folder in the **MATLAB root** box.
3434

35-
![build_environment](https://github.com/mathworks/jenkins-matlab-plugin/assets/48831250/c77220c0-a521-41ad-b0e4-76a6f0afce28)
35+
![environment](https://github.com/user-attachments/assets/00598e0c-468d-465b-b334-5c7ed750ee3f)
3636

3737
4. In the **Build Steps** section, select **Add build step > Run MATLAB Tests**. Then, specify the artifacts to generate in the project workspace. In this example, the plugin generates test results in JUnit-style XML format and code coverage results in Cobertura XML format. Furthermore, to generate the coverage results, the plugin uses only the code in the `source` folder located in the root of the repository. For more information about the build steps provided by the plugin, see [Plugin Configuration Guide](../CONFIGDOC.md).
3838

39-
![run_matlab_tests](https://github.com/mathworks/jenkins-matlab-plugin/assets/48831250/2ef326b7-9b39-4068-83b9-011cebd52506)
39+
![run_matlab_tests](https://github.com/user-attachments/assets/b6b7b811-d998-4fb9-bbf8-5de624bb5bd6)
4040

41-
5. In the **Post-build Actions** section, add two post-build actions to publish the JUnit-style test results and the Cobertura code coverage results. For each artifact, provide the path to the report.
41+
5. In the **Post-build Actions** section, add the **Publish JUnit test result report** post-build action to publish the test results in JUnit-style XML format. Specify the path to the test report in the **Test report XMLs** box.
4242

43-
![post_build](https://github.com/mathworks/jenkins-matlab-plugin/assets/48831250/d584a290-de93-4a9f-8061-00bc2a435c12)
43+
![post_build_junit](https://github.com/user-attachments/assets/82b4c99a-59c3-41e4-946d-555fb9315f35)
4444

45-
6. Click **Save** to save the project configuration settings. You can access and modify your settings at a later stage by selecting **Configure** in the project interface, which displays the project name at the upper-left corner of the page.
45+
6. In the **Post-build Actions** section, add the **Record code coverage results** post-build action to publish the code coverage results in Cobertura XML format. Select `Cobertura Coverage Reports` from the **Coverage Parser** list and specify the path to the coverage report in the **Report File Pattern** box.
46+
47+
![post_build_cobertura](https://github.com/user-attachments/assets/5af14bb9-f12e-4942-a3ad-957eec4a057b)
48+
49+
7. Click **Save** to save the project configuration settings. You can access and modify your settings at a later stage by selecting **Configure** in the project interface, which displays the project name at the upper-left corner of the page.
4650

4751
## Run Tests and Inspect Artifacts
48-
To build your freestyle project, select **Build Now** in the project interface. Jenkins triggers a build, assigns it a number under **Build History**, and runs the build. In this example, the build succeeds because all the tests in the Times Table App project pass.
52+
To build your freestyle project, select **Build Now** in the project interface. Jenkins triggers a build, assigns it a number under **Builds**, and runs the build. In this example, the build succeeds because all the tests in the Times Table App project pass.
4953

5054
Navigate to the project workspace by selecting **Workspace** in the project interface. The generated artifacts are in the `matlabTestArtifacts` folder of the workspace.
5155

52-
![workspace](https://github.com/mathworks/jenkins-matlab-plugin/assets/48831250/5195fb71-6f4f-4261-82c0-501ab953a079)
56+
![workspace](https://github.com/user-attachments/assets/1c1ff1f8-99b7-475f-8278-180ab0185833)
5357

5458
Select **Status** in the project interface. You can access the published artifacts by clicking the **Latest Test Result** and **Coverage Report** links. For example, click the **Latest Test Result** link to view the published JUnit-style test results. On the test results page, click the **(root)** link in the **All Tests** table. The table expands and lists information for each of the test classes within the Times Table App project.
5559

56-
![test_results](https://github.com/mathworks/jenkins-matlab-plugin/assets/48831250/2dc5142d-b844-436c-8e9e-8f7b90c7b69e)
60+
![test_results](https://github.com/user-attachments/assets/51cc73aa-cf8b-455a-b210-7ecfbb772a72)
5761

5862
## See Also
5963
* [Plugin Configuration Guide](../CONFIGDOC.md)<br/>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,4 @@
286286
</plugins>
287287
</pluginManagement>
288288
</build>
289-
</project>
289+
</project>

src/main/java/com/mathworks/ci/MatlabInstallation.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ public void buildEnvVars(EnvVars env) {
6464
if (home == null) {
6565
return;
6666
}
67-
FilePath matlabHome = new FilePath(new File(home));
68-
FilePath matlabBin = new FilePath(matlabHome, "bin");
69-
env.put("PATH+matlabroot", matlabBin.getRemote());
70-
FilePath matlabBatchFolder = matlabHome.getParent();
71-
if (matlabBatchFolder != null) {
72-
env.put("PATH+matlabbatch", matlabBatchFolder.getRemote());
73-
}
67+
env.put("PATH+matlabroot", home + "/bin");
7468
}
7569

7670
public static MatlabInstallation[] getAll() {

src/main/java/com/mathworks/ci/UseMatlabVersionBuildWrapper.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,6 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
201201
if (matlabBinDir == null) {
202202
throw new MatlabNotFoundError(Message.getValue("matlab.not.found.error"));
203203
}
204-
// Add matlab-batch executable in path
205-
FilePath batchExecutable = getNthParentFilePath(matlabExecutablePath, 3);
206-
if (batchExecutable != null && batchExecutable.exists()) {
207-
context.env("PATH+matlabbatch", batchExecutable.getRemote());
208-
}
209204

210205
// Add "matlabroot" without bin as env variable which will be available across
211206
// the build.
@@ -221,19 +216,4 @@ private String getNodeSpecificExecutable(Launcher launcher) {
221216
return (launcher.isUnix()) ? "/bin/matlab" : "\\bin\\matlab.exe";
222217
}
223218

224-
public static FilePath getNthParentFilePath(FilePath path, int levels) {
225-
if (path == null || levels < 0) {
226-
return null;
227-
}
228-
229-
FilePath currentPath = path;
230-
for (int i = 0; i < levels; i++) {
231-
if (currentPath == null) {
232-
return null;
233-
}
234-
currentPath = currentPath.getParent();
235-
}
236-
return currentPath;
237-
}
238-
239219
}

src/main/java/com/mathworks/ci/Utilities.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,14 @@ public static void addMatlabToEnvPathFromAxis(Computer cmp, TaskListener listene
4040
return;
4141
}
4242

43-
FilePath matlabRoot = getNodeSpecificHome(name,
44-
cmp.getNode(), listener, env);
43+
FilePath matlabRoot = getNodeSpecificHome(name, cmp.getNode(), listener, env);
4544

46-
FilePath toolHome = matlabRoot.getParent();
47-
if (toolHome == null) {
48-
return;
49-
}
50-
if (matlabRoot != null && toolHome.exists()) {
51-
env.put("PATH+matlabbatch", toolHome.getRemote());
52-
}
53-
54-
String matlabExecutablePath = getNodeSpecificHome(name,
55-
cmp.getNode(), listener, env).getRemote() + ((Boolean.TRUE.equals(cmp.isUnix())) ? "/bin" : "\\bin");
56-
env.put("PATH+matlabroot", matlabExecutablePath);
45+
FilePath matlabBin = new FilePath(matlabRoot, "bin");
46+
env.put("PATH+matlabroot", matlabBin.getRemote());
5747

5848
// Specify which MATLAB was added to path.
5949
listener.getLogger().println(
60-
"\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabExecutablePath) + "\n");
50+
"\n" + String.format(Message.getValue("matlab.added.to.path.from"), matlabBin.getRemote()) + "\n");
6151
}
6252

6353
public static FilePath getNodeSpecificHome(String instName, Node node, TaskListener listener, EnvVars env)

src/main/java/com/mathworks/ci/tools/MatlabInstaller.java

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.tools;
22

33
/**
4-
* Copyright 2024, The MathWorks, Inc.
4+
* Copyright 2024-2025, The MathWorks, Inc.
55
*/
66

77
import com.mathworks.ci.MatlabInstallation;
@@ -49,7 +49,7 @@ public MatlabInstaller(String id) {
4949
}
5050

5151
public String getRelease() {
52-
return this.release.trim();
52+
return this.release;
5353
}
5454

5555
@DataBoundSetter
@@ -75,10 +75,12 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
7575
String extension = "";
7676
String[] systemProperties = getSystemProperties(node);
7777
FilePath matlabRoot;
78+
MatlabRelease release = parseRelease(this.getRelease());
79+
7880
if (systemProperties[0].toLowerCase().contains("os x")) {
79-
matlabRoot = new FilePath(toolRoot, this.getRelease() + ".app");
81+
matlabRoot = new FilePath(toolRoot, release.name + ".app");
8082
} else {
81-
matlabRoot = new FilePath(toolRoot, this.getRelease());
83+
matlabRoot = new FilePath(toolRoot, release.name);
8284
}
8385
String platform = getPlatform(systemProperties[0], systemProperties[1]);
8486
if (platform == "win64") {
@@ -90,21 +92,24 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
9092

9193
// Download mpm and matlab-batch to temp directory
9294
FilePath mpm = fetchMpm(platform, tempDir);
93-
FilePath matlabBatch = fetchMatlabBatch(platform, tempDir);
95+
FilePath tempMatlabBatch = fetchMatlabBatch(platform, tempDir);
9496

9597
// Install with mpm
96-
mpmInstall(mpm, this.getRelease(), this.getProducts(), matlabRoot, node, log);
98+
mpmInstall(mpm, release, this.getProducts(), matlabRoot, node, log);
9799

98100
// Copy downloaded matlab-batch to tool directory
99-
matlabBatch.copyTo(new FilePath(toolRoot, "matlab-batch" + extension));
101+
FilePath matlabBin = new FilePath(matlabRoot, "bin");
102+
FilePath matlabBatchBin = new FilePath(matlabBin, "matlab-batch" + extension);
103+
tempMatlabBatch.copyTo(matlabBatchBin);
104+
matlabBatchBin.chmod(0777);
100105

101106
// Delete temp directory
102107
tempDir.deleteRecursive();
103108

104109
return matlabRoot;
105110
}
106111

107-
private void mpmInstall(FilePath mpmPath, String release, String products, FilePath destination, Node node,
112+
private void mpmInstall(FilePath mpmPath, MatlabRelease release, String products, FilePath destination, Node node,
108113
TaskListener log)
109114
throws IOException, InterruptedException {
110115
makeDir(destination);
@@ -114,7 +119,10 @@ private void mpmInstall(FilePath mpmPath, String release, String products, FileP
114119
ArgumentListBuilder args = new ArgumentListBuilder();
115120
args.add(mpmPath.getRemote());
116121
args.add("install");
117-
appendReleaseToArguments(release, args, log);
122+
args.add("--release=" + release.name);
123+
if (release.isPrerelease) {
124+
args.add("--release-status=Prerelease");
125+
}
118126
args.add("--destination=" + destination.getRemote());
119127
addMatlabProductsToArgs(args, products);
120128

@@ -144,29 +152,29 @@ private void makeDir(FilePath path) throws IOException, InterruptedException {
144152
}
145153
}
146154

147-
private void appendReleaseToArguments(String release, ArgumentListBuilder args, TaskListener log) {
148-
String trimmedRelease = release.trim();
149-
String actualRelease = trimmedRelease;
155+
private MatlabRelease parseRelease(String release) throws InstallationFailedException {
156+
String name = release.trim();
157+
boolean isPrerelease = false;
150158

151-
if (trimmedRelease.equalsIgnoreCase("latest") || trimmedRelease.equalsIgnoreCase(
152-
"latest-including-prerelease")) {
153-
String releaseInfoUrl = Message.getValue("matlab.release.info.url") + trimmedRelease;
154-
String releaseVersion = null;
159+
if (name.equalsIgnoreCase("latest") || name.equalsIgnoreCase("latest-including-prerelease")) {
160+
String releaseInfoUrl = Message.getValue("matlab.release.info.url") + name;
155161
try {
156-
releaseVersion = IOUtils.toString(new URL(releaseInfoUrl),
157-
StandardCharsets.UTF_8).trim();
162+
name = IOUtils.toString(new URL(releaseInfoUrl), StandardCharsets.UTF_8).trim();
158163
} catch (IOException e) {
159-
log.getLogger().println("Failed to fetch release version: " + e.getMessage());
164+
throw new InstallationFailedException("Failed to fetch release version: " + e.getMessage());
160165
}
161166

162-
if (releaseVersion != null && releaseVersion.contains("prerelease")) {
163-
actualRelease = releaseVersion.replace("prerelease", "");
164-
args.add("--release-status=Prerelease");
165-
} else {
166-
actualRelease = releaseVersion;
167+
if (name.contains("prerelease")) {
168+
name = name.replace("prerelease", "");
169+
isPrerelease = true;
167170
}
168171
}
169-
args.add("--release=" + actualRelease);
172+
173+
if (name.startsWith("r")) {
174+
name = name.replaceFirst("r", "R");
175+
}
176+
177+
return new MatlabRelease(name, isPrerelease);
170178
}
171179

172180
private FilePath fetchMpm(String platform, FilePath destination)
@@ -223,7 +231,6 @@ private FilePath fetchMatlabBatch(String platform, FilePath destination)
223231
FilePath matlabBatchPath = new FilePath(destination, "matlab-batch" + extension);
224232
try {
225233
matlabBatchPath.copyFrom(matlabBatchUrl.openStream());
226-
matlabBatchPath.chmod(0777);
227234
} catch (IOException | InterruptedException e) {
228235
throw new InstallationFailedException("Unable to setup matlab-batch.");
229236
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.mathworks.ci.tools;
2+
3+
/**
4+
* Copyright 2025, The MathWorks, Inc.
5+
*/
6+
7+
public class MatlabRelease {
8+
public String name;
9+
public boolean isPrerelease;
10+
11+
public MatlabRelease(String name, boolean isPrerelease) {
12+
this.name = name;
13+
this.isPrerelease = isPrerelease;
14+
}
15+
}

src/main/resources/com/mathworks/ci/tools/MatlabInstaller/help-release.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@
1414
<strong>Example:</strong> latest <br>
1515
<strong>Example:</strong> R2023bU4 <br>
1616
</p>
17-
<p>
18-
<strong>Note:</strong> The plugin does not install dependencies on a Linux platform. If you are using a Linux platform,
19-
verify that the required software is available before installing products using MATLAB Package Manager. For more information, see
20-
<a href="https://in.mathworks.com/help/install/ug/get-mpm-os-command-line.html">Get MATLAB Package Manager.</a>
21-
</p>
22-
</div>
17+
</div>

0 commit comments

Comments
 (0)