diff --git a/src/main/resources/+ciplugins/+jenkins/BuildReportPlugin.m b/src/main/resources/+ciplugins/+jenkins/BuildReportPlugin.m index ccdfbd94..8e810e57 100644 --- a/src/main/resources/+ciplugins/+jenkins/BuildReportPlugin.m +++ b/src/main/resources/+ciplugins/+jenkins/BuildReportPlugin.m @@ -6,20 +6,24 @@ function runTaskGraph(plugin, pluginData) runTaskGraph@matlab.buildtool.plugins.BuildRunnerPlugin(plugin, pluginData); - fID = fopen(fullfile(getenv("WORKSPACE"),'.matlab/buildArtifact.json'), 'w'); - taskDetails = struct(); - for idx = 1:numel(pluginData.TaskResults) - taskDetails(idx).name = pluginData.TaskResults(idx).Name; - taskDetails(idx).description = pluginData.TaskGraph.Tasks(idx).Description; - taskDetails(idx).failed = pluginData.TaskResults(idx).Failed; - taskDetails(idx).skipped = pluginData.TaskResults(idx).Skipped; - taskDetails(idx).duration = string(pluginData.TaskResults(idx).Duration); + [fID, msg] = fopen(fullfile(getenv("WORKSPACE"),".matlab/buildArtifact.json"), "w"); + + if fID == -1 + warning("ciplugins:jenkins:BuildReportPlugin:UnableToOpenFile","Could not open a file for Jenkins build result table due to: %s", msg); + else + closeFile = onCleanup(@()fclose(fID)); + taskDetails = struct(); + for idx = 1:numel(pluginData.TaskResults) + taskDetails(idx).name = pluginData.TaskResults(idx).Name; + taskDetails(idx).description = pluginData.TaskGraph.Tasks(idx).Description; + taskDetails(idx).failed = pluginData.TaskResults(idx).Failed; + taskDetails(idx).skipped = pluginData.TaskResults(idx).Skipped; + taskDetails(idx).duration = string(pluginData.TaskResults(idx).Duration); + end + a = struct("taskDetails",taskDetails); + s = jsonencode(a,PrettyPrint=true); + fprintf(fID, "%s",s); end - a = struct("taskDetails",taskDetails); - s = jsonencode(a,"PrettyPrint",true); - fprintf(fID, '%s',s); - fclose(fID); end - end end \ No newline at end of file diff --git a/src/main/resources/com/mathworks/ci/BuildArtifactAction/summary.jelly b/src/main/resources/com/mathworks/ci/BuildArtifactAction/summary.jelly index ee5beef9..b738b03f 100644 --- a/src/main/resources/com/mathworks/ci/BuildArtifactAction/summary.jelly +++ b/src/main/resources/com/mathworks/ci/BuildArtifactAction/summary.jelly @@ -9,7 +9,7 @@
Tasks run: ${it.totalCount}