diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
new file mode 100644
index 00000000..aa785481
--- /dev/null
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -0,0 +1,56 @@
+const buildCardTemplateSource = jQuery("#build-card-template").html();
+const projectCardTemplateSource = jQuery("#project-card-template").html();
+const refreshFrequency = parseInt(document.querySelector(".pipeline-refresh-frequency").dataset.refreshFrequency, 10);
+
+var buildPipeline = new BuildPipeline(
+buildPipelineViewProxy,
+Handlebars.compile(buildCardTemplateSource),
+Handlebars.compile(projectCardTemplateSource),
+refreshFrequency
+);
+
+
+function initializeBuildCards() {
+ // Find all build data elements
+ document.querySelectorAll('.build-data').forEach(buildElement => {
+
+ const buildId = buildElement.dataset.buildId;
+ const buildData = JSON.parse(buildElement.dataset.buildInfo);
+ const buildStatus = buildElement.dataset.buildStatus;
+ const isManualTrigger = buildElement.dataset.isManualTrigger === 'true';
+ const nextBuildNumber = parseInt(buildElement.dataset.nextBuildNumber, 10);
+ console.log(nextBuildNumber);
+ const dependencyIds = buildElement.dataset.dependencyIds
+ .split(',')
+ .filter(Boolean)
+ .map(id => parseInt(id, 10));
+
+
+ // Generate build card
+ jQuery(buildElement).append(buildPipeline.buildCardTemplate(buildData));
+
+ // add build proxy to proxies for future use-->
+ buildPipeline.buildProxies[buildId] = window[`buildProxy_${buildId}`];
+
+ if (buildStatus === 'BUILDING') {
+ buildPipeline.showProgress(buildId, dependencyIds, nextBuildNumber);
+ }
+
+ if (buildStatus === 'PENDING') {
+ jQuery("table.pipelines").on(`show-status-${buildId}`, function() {
+ if (isManualTrigger) {
+ buildPipeline.updateBuildCard(buildId);
+ } else {
+ buildPipeline.updateNextBuildAndShowProgress(
+ buildId,
+ nextBuildNumber,
+ dependencyIds
+ );
+ }
+ });
+ }
+
+ });
+}
+
+document.addEventListener('DOMContentLoaded', initializeBuildCards);
\ No newline at end of file
diff --git a/src/main/webapp/js/build-pipeline.js b/src/main/webapp/js/build-pipeline.js
index 6ce69423..3d650c9d 100644
--- a/src/main/webapp/js/build-pipeline.js
+++ b/src/main/webapp/js/build-pipeline.js
@@ -26,7 +26,7 @@ BuildPipeline.prototype = {
buildPipeline.updateAllBuildCards(dependencies);
// trigger all dependency tracking
jQuery.each(dependencies, function(){
- jQuery("#pipelines").trigger("show-status-" + this);
+ jQuery("table.pipelines").trigger("show-status-" + this);
});
}
});
From 86b17503e71710c2a0aa8f7127909f7c291ec839 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Sun, 3 Nov 2024 17:04:09 -0500
Subject: [PATCH 2/9] extract inline script bpp.jelly
---
.../hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly | 5 -----
.../buildpipeline/BuildPipelineView/build-pipeline-init.js | 2 +-
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index e7b1ea91..267e61ee 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -34,11 +34,6 @@
-
-
-
-
-
Date: Mon, 4 Nov 2024 16:48:30 -0500
Subject: [PATCH 3/9] fix existing functionality - extract JS
---
.../buildpipeline/BuildPipelineView/bpp.jelly | 5 ++---
.../BuildPipelineView/build-pipeline-init.js | 17 ++++++-----------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index 267e61ee..f3e42b9e 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -130,14 +130,13 @@
-
-
+ data-dependency-ids="${build.getDependencyIds()}"/>
|
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index 734d2cf1..268da39b 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -3,10 +3,10 @@ const projectCardTemplateSource = jQuery("#project-card-template").html();
const refreshFrequency = parseInt(document.querySelector(".pipeline-refresh-frequency").dataset.refreshFrequency, 10);
var buildPipeline = new BuildPipeline(
-buildPipelineViewProxy,
-Handlebars.compile(buildCardTemplateSource),
-Handlebars.compile(projectCardTemplateSource),
-refreshFrequency
+ buildPipelineViewProxy,
+ Handlebars.compile(buildCardTemplateSource),
+ Handlebars.compile(projectCardTemplateSource),
+ refreshFrequency
);
@@ -19,12 +19,7 @@ function initializeBuildCards() {
const buildStatus = buildElement.dataset.buildStatus;
const isManualTrigger = buildElement.dataset.isManualTrigger === 'true';
const nextBuildNumber = parseInt(buildElement.dataset.nextBuildNumber, 10);
- console.log(nextBuildNumber);
- const dependencyIds = buildElement.dataset.dependencyIds
- .split(',')
- .filter(Boolean)
- .map(id => parseInt(id, 10));
-
+ const dependencyIds = JSON.parse(buildElement.dataset.dependencyIds);
// Generate build card
jQuery(buildElement).append(buildPipeline.buildCardTemplate(buildData));
@@ -33,7 +28,7 @@ function initializeBuildCards() {
buildPipeline.buildProxies[buildId] = window[`buildProxy_${buildId}`];
if (buildStatus === 'BUILDING') {
- buildPipeline.showProgress(buildId, dependencyIds, nextBuildNumber);
+ buildPipeline.showProgress(buildId, dependencyIds);
}
if (buildStatus === 'PENDING') {
From 08c66cab0458dc5693da6db178c99140823e64f8 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Mon, 4 Nov 2024 16:49:30 -0500
Subject: [PATCH 4/9] fix existing functionality - extract JS
---
.../buildpipeline/BuildPipelineView/build-pipeline-init.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index 268da39b..2987cde3 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -11,7 +11,6 @@ var buildPipeline = new BuildPipeline(
function initializeBuildCards() {
- // Find all build data elements
document.querySelectorAll('.build-data').forEach(buildElement => {
const buildId = buildElement.dataset.buildId;
From da580f07ae03fbf3127a52f12fb8783fb7083428 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Thu, 7 Nov 2024 18:57:29 -0500
Subject: [PATCH 5/9] fix card update logic
---
.../BuildPipelineView/build-pipeline-init.js | 25 ++++++++-----------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index 2987cde3..6b925b0b 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -30,20 +30,17 @@ function initializeBuildCards() {
buildPipeline.showProgress(buildId, dependencyIds);
}
- if (buildStatus === 'PENDING') {
- jQuery("table.pipelines").on(`show-status-${buildId}`, function() {
- if (isManualTrigger) {
- buildPipeline.updateBuildCard(buildId);
- } else {
- buildPipeline.updateNextBuildAndShowProgress(
- buildId,
- nextBuildNumber,
- dependencyIds
- );
- }
- });
- }
-
+ jQuery("table.pipelines").on(`show-status-${buildId}`, function() {
+ if (isManualTrigger) {
+ buildPipeline.updateBuildCard(buildId);
+ } else {
+ buildPipeline.updateNextBuildAndShowProgress(
+ buildId,
+ nextBuildNumber,
+ dependencyIds
+ );
+ }
+ });
});
}
From 7c2f8cb534168bb944d37445820981edf08e8b8a Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Fri, 8 Nov 2024 15:53:14 -0500
Subject: [PATCH 6/9] split seaparate fix to
https://github.com/jenkinsci/build-pipeline-plugin/pull/158
---
src/main/webapp/js/build-pipeline.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/webapp/js/build-pipeline.js b/src/main/webapp/js/build-pipeline.js
index 3d650c9d..6ce69423 100644
--- a/src/main/webapp/js/build-pipeline.js
+++ b/src/main/webapp/js/build-pipeline.js
@@ -26,7 +26,7 @@ BuildPipeline.prototype = {
buildPipeline.updateAllBuildCards(dependencies);
// trigger all dependency tracking
jQuery.each(dependencies, function(){
- jQuery("table.pipelines").trigger("show-status-" + this);
+ jQuery("#pipelines").trigger("show-status-" + this);
});
}
});
From 2b9bef5bbe0116e43ccbb7cda4020a714329f6a8 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Mon, 11 Nov 2024 14:48:46 -0500
Subject: [PATCH 7/9] cleanup
---
.../BuildPipelineView/build-pipeline-init.js | 24 ++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index 6b925b0b..d5ca125f 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -30,17 +30,19 @@ function initializeBuildCards() {
buildPipeline.showProgress(buildId, dependencyIds);
}
- jQuery("table.pipelines").on(`show-status-${buildId}`, function() {
- if (isManualTrigger) {
- buildPipeline.updateBuildCard(buildId);
- } else {
- buildPipeline.updateNextBuildAndShowProgress(
- buildId,
- nextBuildNumber,
- dependencyIds
- );
- }
- });
+ if (buildStatus === 'BUILDING') {
+ jQuery("table.pipelines").on(`show-status-${buildId}`, function () {
+ if (isManualTrigger) {
+ buildPipeline.updateBuildCard(buildId);
+ } else {
+ buildPipeline.updateNextBuildAndShowProgress(
+ buildId,
+ nextBuildNumber,
+ dependencyIds
+ );
+ }
+ });
+ }
});
}
From d31cab36edcfcfb85d1f2c59733b5216ef46b419 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Mon, 11 Nov 2024 15:24:07 -0500
Subject: [PATCH 8/9] cleanup
---
.../BuildPipelineView/build-pipeline-init.js | 24 +++++++++----------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index d5ca125f..8aa65c1d 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -30,19 +30,17 @@ function initializeBuildCards() {
buildPipeline.showProgress(buildId, dependencyIds);
}
- if (buildStatus === 'BUILDING') {
- jQuery("table.pipelines").on(`show-status-${buildId}`, function () {
- if (isManualTrigger) {
- buildPipeline.updateBuildCard(buildId);
- } else {
- buildPipeline.updateNextBuildAndShowProgress(
- buildId,
- nextBuildNumber,
- dependencyIds
- );
- }
- });
- }
+ jQuery("table.pipelines").on(`show-status-${buildId}`, function () {
+ if (isManualTrigger) {
+ buildPipeline.updateBuildCard(buildId);
+ } else {
+ buildPipeline.updateNextBuildAndShowProgress(
+ buildId,
+ nextBuildNumber,
+ dependencyIds
+ );
+ }
+ });
});
}
From 41490e9c67430958e5229fd3d504763831812857 Mon Sep 17 00:00:00 2001
From: shlomomdahan <64103471+shlomomdahan@users.noreply.github.com>
Date: Tue, 12 Nov 2024 13:19:25 -0500
Subject: [PATCH 9/9] address comments to simplify
---
.../hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly | 4 ++--
.../buildpipeline/BuildPipelineView/build-pipeline-init.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
index f3e42b9e..db430bc3 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/bpp.jelly
@@ -19,13 +19,13 @@
-
+
-
+
diff --git a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
index 8aa65c1d..e00f2cee 100644
--- a/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
+++ b/src/main/resources/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView/build-pipeline-init.js
@@ -1,6 +1,6 @@
const buildCardTemplateSource = jQuery("#build-card-template").html();
const projectCardTemplateSource = jQuery("#project-card-template").html();
-const refreshFrequency = parseInt(document.querySelector(".pipeline-refresh-frequency").dataset.refreshFrequency, 10);
+const refreshFrequency = parseInt(document.querySelector(".pipeline-refresh-frequency").dataset.refreshFrequency);
var buildPipeline = new BuildPipeline(
buildPipelineViewProxy,
|