Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev main #357

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ src/main/resources/matlab-script-generator.zip
src/main/resources/**/run-matlab-command*
src/main/resources/license.txt

.idea/

**/.DS_Store
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trigger:
- master

steps:
- task: Maven@3
- task: Maven@4
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m -Dmaven.javadoc.skip=true'
Expand Down
38 changes: 30 additions & 8 deletions src/main/java/com/mathworks/ci/BuildArtifactAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.mathworks.ci;

/**
* Copyright 2024 The MathWorks, Inc.
*
*/

import hudson.FilePath;
import hudson.model.Action;
import hudson.model.Run;
Expand All @@ -18,15 +23,13 @@
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;


public class BuildArtifactAction implements Action {
private Run<?, ?> build;
private int totalCount;
private int skipCount;
private int failCount;
private String actionID;
private static final String ROOT_ELEMENT = "taskDetails";
private static final String BUILD_ARTIFACT_FILE = "buildArtifact";

public BuildArtifactAction(Run<?, ?> build, String actionID) {
this.build = build;
Expand Down Expand Up @@ -69,10 +72,10 @@ public List<BuildArtifactData> getBuildArtifact() throws ParseException, Interru
FilePath fl;
if(this.actionID == null){
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
BUILD_ARTIFACT_FILE + ".json"));
MatlabBuilderConstants.BUILD_ARTIFACT + ".json"));
} else {
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
BUILD_ARTIFACT_FILE + this.actionID + ".json"));
MatlabBuilderConstants.BUILD_ARTIFACT + this.actionID + ".json"));
}
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
Object obj = new JSONParser().parse(reader);
Expand Down Expand Up @@ -141,16 +144,15 @@ public void setOwner(Run owner) {
this.build = owner;
}


private void setCounts() throws InterruptedException, ParseException {
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
FilePath fl;
if(this.actionID == null){
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
BUILD_ARTIFACT_FILE + ".json"));
MatlabBuilderConstants.BUILD_ARTIFACT + ".json"));
} else {
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
BUILD_ARTIFACT_FILE + this.actionID + ".json"));
MatlabBuilderConstants.BUILD_ARTIFACT + this.actionID + ".json"));
}
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
Object obj = new JSONParser().parse(reader);
Expand Down Expand Up @@ -204,7 +206,7 @@ private void setCounts() throws InterruptedException, ParseException {
private void iterateAllTaskAttributes(Entry pair, BuildArtifactData data) {
// Iterates across all task attributes and updates
String key = pair.getKey().toString();
switch(key.toLowerCase()){
switch(key){
case "duration":
data.setTaskDuration(pair.getValue().toString());
break;
Expand All @@ -220,6 +222,26 @@ private void iterateAllTaskAttributes(Entry pair, BuildArtifactData data) {
case "skipped":
data.setTaskSkipped((Boolean) pair.getValue());
break;
case "skipReason":
String skipReasonKey = pair.getValue().toString();
String skipReason;
switch(skipReasonKey){
case "UpToDate":
skipReason = "up-to-date";
break;
case "UserSpecified":
case "UserRequested":
skipReason = "user requested";
break;
case "DependencyFailed":
skipReason = "dependency failed";
break;
default:
skipReason = skipReasonKey;
break;
}
data.setSkipReason(skipReason);
break;
default :
break;
}
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/com/mathworks/ci/BuildArtifactData.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.mathworks.ci;

/**
* Copyright 2024 The MathWorks, Inc.
*
*/

public class BuildArtifactData {

private String taskName;
Expand All @@ -8,11 +13,11 @@ public class BuildArtifactData {

private String taskDescription;
private boolean taskSkipped;
private String skipReason;

public BuildArtifactData() {
}


public String getTaskDuration() {
return this.taskDuration;
}
Expand All @@ -37,6 +42,14 @@ public void setTaskSkipped(boolean taskSkipped) {
this.taskSkipped = taskSkipped;
}

public String getSkipReason() {
return (this.skipReason == null) ? "" : this.skipReason;
}

public void setSkipReason(String skipReason) {
this.skipReason = skipReason;
}

public boolean getTaskFailed() {
return this.taskFailed;
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mathworks/ci/BuildConsoleAnnotator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.mathworks.ci;

/**
* Copyright 2024 The MathWorks, Inc.
*
*/

import com.google.common.base.Charsets;
import hudson.console.ConsoleLogFilter;
import hudson.console.LineTransformationOutputStream;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mathworks/ci/BuildTargetNote.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.mathworks.ci;

/**
* Copyright 2024 The MathWorks, Inc.
*
*/

import com.google.common.annotations.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/mathworks/ci/FormValidationUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* This is Utility class which provides commonly used methods for form validations across builders
*
*/

import java.util.List;
import java.util.function.Function;
import hudson.util.FormValidation;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/mathworks/ci/ListenerLogDecorator.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.mathworks.ci;

/*
* Copyright 2018 The MathWorks, Inc.
*/
Expand Down
143 changes: 0 additions & 143 deletions src/main/java/com/mathworks/ci/MatlabBuild.java

This file was deleted.

7 changes: 7 additions & 0 deletions src/main/java/com/mathworks/ci/MatlabBuilderConstants.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.mathworks.ci;

/*
* Copyright 2019-2020 The MathWorks, Inc.
*/
Expand Down Expand Up @@ -32,6 +33,12 @@ public class MatlabBuilderConstants {

//Temporary MATLAB folder name in workspace
public static final String TEMP_MATLAB_FOLDER_NAME = ".matlab";

// MATLAB default function/plugin paths
public static final String DEFAULT_PLUGIN = "+ciplugins/+jenkins/getDefaultPlugins.m";
public static final String BUILD_REPORT_PLUGIN = "+ciplugins/+jenkins/BuildReportPlugin.m";
public static final String TASK_RUN_PROGRESS_PLUGIN = "+ciplugins/+jenkins/TaskRunProgressPlugin.m";
public static final String BUILD_ARTIFACT = "buildArtifact";

public static final String NEW_LINE = System.getProperty("line.separator");

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mathworks/ci/MatlabExecutionException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.mathworks.ci;

/**
* Copyright 2021 The MathWorks, Inc.
*
*/

import java.lang.Exception;

public class MatlabExecutionException extends Exception {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/mathworks/ci/MatlabNotFoundError.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*
*/

import java.io.FileNotFoundException;

public class MatlabNotFoundError extends Error {

private static final long serialVersionUID = 7918595075502022644L;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/mathworks/ci/MatlabReleaseInfo.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.mathworks.ci;

import java.io.BufferedReader;

/*
* Copyright 2019 The MathWorks, Inc. This Class provides MATLAB release information in the form of
* Version numbers. Class constructor requires MATLAB root as input parameter
*/

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.NotDirectoryException;
import java.util.HashMap;
Expand All @@ -26,7 +25,6 @@
import org.w3c.dom.NodeList;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.FilePath;
import org.xml.sax.SAXException;

public class MatlabReleaseInfo {
private FilePath matlabRoot;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/mathworks/ci/MatrixPatternResolver.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.mathworks.ci;

/*
* Copyright 2019 The MathWorks, Inc.
*
Expand Down
Loading