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

DRAFT FOR TESTING - CSP TICKETS #152

Draft
wants to merge 89 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
16aad96
fix: Update jQuery filter removal syntax for 3.x compatibility
shlomomdahan Oct 23, 2024
d74f129
address first csp issue: https://github.com/jenkinsci/build-pipeline-…
shlomomdahan Oct 23, 2024
317e0fa
address first csp issue: https://github.com/jenkinsci/build-pipeline-…
shlomomdahan Oct 23, 2024
913d01a
line 97: https://github.com/jenkinsci/build-pipeline-plugin/blob/mast…
shlomomdahan Oct 23, 2024
6537326
Merge branch 'master' into JENKINS-73960
shlomomdahan Oct 28, 2024
31008b1
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan Oct 29, 2024
85d08a3
fix:https://github.com/jenkinsci/build-pipeline-plugin/blob/master/sr…
shlomomdahan Oct 29, 2024
f5f7cc7
fix:https://github.com/jenkinsci/build-pipeline-plugin/blob/master/sr…
shlomomdahan Oct 29, 2024
2147df2
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan Oct 30, 2024
047a747
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan Oct 30, 2024
6ef4240
fix: https://github.com/jenkinsci/build-pipeline-plugin/blob/master/s…
shlomomdahan Oct 30, 2024
a3b8458
dynamic behaviour.specify
shlomomdahan Oct 30, 2024
ed0c9e5
dynamic behaviour.specify
shlomomdahan Oct 30, 2024
30476d5
update names, update java method, all working
shlomomdahan Oct 30, 2024
5572051
remove Behaviour.specify \ Use dynamic approach
shlomomdahan Oct 30, 2024
ba67a4b
remove Behaviour.specify \ Use dynamic approach
shlomomdahan Oct 30, 2024
9bf83a9
remove Behaviour.specify \ Use dynamic approach
shlomomdahan Oct 30, 2024
b5ccdd4
Extract event handlers in
shlomomdahan Oct 30, 2024
85dcb4b
Extract event handlers in
shlomomdahan Oct 30, 2024
e40e43b
Extract event handlers in
shlomomdahan Oct 30, 2024
ab387f7
Extract inline script block in au/com/centrumsystems/hudson/plugin/bu…
shlomomdahan Oct 30, 2024
943b8d9
Extract inline script block in au/com/centrumsystems/hudson/plugin/bu…
shlomomdahan Oct 30, 2024
8ae55a0
Extract inline script block in au/com/centrumsystems/hudson/plugin/bu…
shlomomdahan Oct 30, 2024
187fb83
extract inline script in
shlomomdahan Oct 30, 2024
b65fcf0
extract inline script in
shlomomdahan Oct 31, 2024
5b073d9
extract inline script in
shlomomdahan Oct 31, 2024
c649a4c
extract inline script in
shlomomdahan Oct 31, 2024
59e2952
rerun tests
shlomomdahan Oct 31, 2024
cbe19f0
Extract JS in columnHeaders.jelly
shlomomdahan Oct 31, 2024
ccdfa1d
Extract JS in columnHeaders.jelly
shlomomdahan Oct 31, 2024
c35d193
test
shlomomdahan Oct 31, 2024
41a2f9c
test
shlomomdahan Oct 31, 2024
85e53a3
extract inmline JS in main_dashboard.jelly
shlomomdahan Oct 31, 2024
87fd88d
Merge branch 'JENKINS-73961' into test-csp-all-tickets
shlomomdahan Nov 3, 2024
680520e
Merge branch 'JENKINS-74053' into test-csp-all-tickets
shlomomdahan Nov 3, 2024
5b9a97f
Merge branch 'JENKINS-74054' into test-csp-all-tickets
shlomomdahan Nov 3, 2024
4028993
Merge branch 'JENKINS-74055' into test-csp-all-tickets
shlomomdahan Nov 3, 2024
03c51bb
Merge branch 'JENKINS-74056' into test-csp-all-tickets
shlomomdahan Nov 3, 2024
90eb197
Merge branch 'JENKINS-74057' into test-csp-all-tickets
shlomomdahan Nov 3, 2024
7316cdd
extract inline script bpp.jelly
shlomomdahan Nov 3, 2024
86b1750
extract inline script bpp.jelly
shlomomdahan Nov 3, 2024
5dab851
fix existing functionality - extract JS
shlomomdahan Nov 4, 2024
08c66ca
fix existing functionality - extract JS
shlomomdahan Nov 4, 2024
b99d5c3
Merge branch 'JENKINS-74806' into test-csp-all-tickets
shlomomdahan Nov 4, 2024
3239f81
test all tickets
shlomomdahan Nov 4, 2024
0ef7e3c
bump jenkins to 2.426.3 (to update jQuery3 plugin)
shlomomdahan Nov 4, 2024
e3da59e
Merge branch 'bump-jenkins-to-2.426.3' into test-csp-all-tickets
shlomomdahan Nov 4, 2024
edabfbf
Bump jenkins version to 2.452.3
shlomomdahan Nov 5, 2024
c9ad9c0
Bump jenkins version to 2.452.3
shlomomdahan Nov 5, 2024
f490066
Bump jenkins version to 2.452.3
shlomomdahan Nov 5, 2024
3599964
Merge branch 'bump-jenkins-to-2.452.3' into test-csp-all-tickets
shlomomdahan Nov 5, 2024
f493512
simplify proxy
shlomomdahan Nov 5, 2024
5abeaf3
Merge branch 'JENKINS-74056' into test-csp-all-tickets
shlomomdahan Nov 5, 2024
0a4c4fe
return positive ids
shlomomdahan Nov 6, 2024
dbbcc7d
return positive ids
shlomomdahan Nov 6, 2024
b7cd6b2
Merge branch 'JENKINS-74056' into test-csp-all-tickets
shlomomdahan Nov 6, 2024
8fedd28
Bad attempt to compute absolute value of signed 32-bit hashcode in au…
shlomomdahan Nov 6, 2024
e8c4859
Merge branch 'JENKINS-74056' into test-csp-all-tickets
shlomomdahan Nov 6, 2024
874f74e
mask negative bit in project id
shlomomdahan Nov 6, 2024
d12a71e
Merge branch 'JENKINS-74056' into test-csp-all-tickets
shlomomdahan Nov 6, 2024
7beca34
specify pipeline wrapper - fixes onclick issues
shlomomdahan Nov 7, 2024
7ba7e0b
Merge branch 'JENKINS-73960' into test-csp-all-tickets
shlomomdahan Nov 7, 2024
188bc43
select all pipeline wrappers - incase multiple builds selected
shlomomdahan Nov 7, 2024
5462883
Merge branch 'JENKINS-73960' into test-csp-all-tickets
shlomomdahan Nov 7, 2024
da580f0
fix card update logic
shlomomdahan Nov 7, 2024
d377b25
Merge branch 'JENKINS-74806' into test-csp-all-tickets
shlomomdahan Nov 7, 2024
2805d64
restore pom
shlomomdahan Nov 8, 2024
95aba1e
restore pom
shlomomdahan Nov 8, 2024
8a4cab4
update BOM to support 2.452.3 and jQuery 3.7.1-2
shlomomdahan Nov 8, 2024
6537857
Merge branch 'bump-jenkins-to-2.452.3' into test-csp-all-tickets
shlomomdahan Nov 8, 2024
fdfa404
delete unused handlebar helpers
shlomomdahan Nov 8, 2024
b58990c
delete unused handlebar helpers
shlomomdahan Nov 8, 2024
48c5392
Merge branch 'master' into JENKINS-73961
shlomomdahan Nov 8, 2024
bacdf49
remove redundant class
shlomomdahan Nov 8, 2024
7fb5e63
Merge branch 'master' into JENKINS-74054
shlomomdahan Nov 8, 2024
e369daf
remove redundant class
shlomomdahan Nov 8, 2024
f3408d8
remove redundant class
shlomomdahan Nov 8, 2024
77e4e6e
Merge branch 'master' into test-csp-all-tickets
shlomomdahan Nov 8, 2024
8bbcce2
Merge branch 'JENKINS-73961' into test-csp-all-tickets
shlomomdahan Nov 8, 2024
4d55b81
Merge branch 'JENKINS-74054' into test-csp-all-tickets
shlomomdahan Nov 8, 2024
8518c67
Merge branch 'JENKINS-74057' into test-csp-all-tickets
shlomomdahan Nov 8, 2024
b456e59
Merge branch 'master' into JENKINS-73960
shlomomdahan Nov 8, 2024
16ccf5b
Merge branch 'master' into JENKINS-73961
shlomomdahan Nov 8, 2024
cfae875
remove redundant span, add attributes to trigger span
shlomomdahan Nov 8, 2024
8e66cab
Merge branch 'master' into JENKINS-73960
shlomomdahan Nov 8, 2024
d8bffb3
Merge branch 'master' into test-csp-all-tickets
shlomomdahan Nov 10, 2024
b3e23da
remove redundant parameters span
shlomomdahan Nov 10, 2024
486dc2f
Merge branch 'JENKINS-73960' into test-csp-all-tickets
shlomomdahan Nov 10, 2024
0b954b9
Merge branch 'JENKINS-73961' into test-csp-all-tickets
shlomomdahan Nov 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static boolean isManualTrigger(final AbstractProject<?, ?> upstreamProjec
final String manualDownstreamProjects = ((BuildPipelineTrigger) upstreamPub).getDownstreamProjectNames();
final String[] downstreamProjs = manualDownstreamProjects.split(",");
for (final String nextProj : downstreamProjs) {
if (Jenkins.getInstance().getItem(nextProj.trim(), upstreamProject) == downstreamProject) {
if (Jenkins.getInstance().getItem(nextProj.trim(), upstreamProject).getName().equals(downstreamProject.getName())) {
manualTrigger = true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Behaviour.specify(".bpp-trigger-pipeline-parameterized", 'BuildPipelineView.TriggerPipelineParameterized', 0, function(element) {
element.addEventListener('click', function() {
const href = element.dataset.fillDialogHref;
const title = element.dataset.fillDialogTitle;
buildPipeline.fillDialog(href, title);
});
});

Behaviour.specify("#trigger-pipeline-button", 'BuildPipelineView.TriggerPipeline', 0, function(element) {
element.addEventListener('click', function(e) {
document.getElementById('triggerPipelineForm').submit();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,30 @@
</j:if>

<st:adjunct includes="io.jenkins.plugins.jquery3"/>
<st:adjunct includes="au.com.centrumsystems.hudson.plugin.buildpipeline.extension.BuildCardExtension.build-card-template-onclicks"/>
<st:adjunct includes="au.com.centrumsystems.hudson.plugin.buildpipeline.BuildPipelineView.bpp-trigger-pipeline"/>
<script src="${rootURL}/plugin/build-pipeline-plugin/js/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="${rootURL}/plugin/build-pipeline-plugin/js/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript" src="${rootURL}/plugin/build-pipeline-plugin/js/handlebars-1.0.0.beta.6.js"></script>
<script src="${rootURL}/plugin/build-pipeline-plugin/js/jquery.fancybox-1.3.4.js"></script>
<script src="${rootURL}/plugin/build-pipeline-plugin/js/jquery.tooltip.min.js"></script>
<script src="${rootURL}/plugin/build-pipeline-plugin/js/build-pipeline.js"></script>

<script id="build-card-template" type="text/x-handlebars-template">
<span id="build-card-template" type="text/x-handlebars-template" style="display: none">
<st:include page="buildCardTemplate.jelly"
from="${from.getBuildCard()}"
it="${from}"/>
</script>
</span>

<script id="project-card-template" type="text/x-handlebars-template">
<span id="project-card-template" type="text/x-handlebars-template" style="display: none">
<st:include page="projectCardTemplate.jelly"
from="${from.getColumnHeaders()}"
it="${from}" />
</script>
</span>

<st:bind var="buildPipelineViewProxy" value="${from}" />
<script type="text/javascript">
var buildCardTemplateSource = jQuery("#build-card-template").html();
var projectCardTemplateSource = jQuery("#project-card-template").html();
var buildPipeline = new BuildPipeline(buildPipelineViewProxy, Handlebars.compile(buildCardTemplateSource), Handlebars.compile(projectCardTemplateSource), ${from.getRefreshFrequencyInMillis()});
</script>
<span class="pipeline-refresh-frequency" data-refresh-frequency="${from.getRefreshFrequencyInMillis()}" style="display: none"/>
<st:adjunct includes="au.com.centrumsystems.hudson.plugin.buildpipeline.BuildPipelineView.build-pipeline-init"/>

<st:include page="buildCardHelpers.jelly"
from="${from.getBuildCard()}"
Expand All @@ -62,13 +61,13 @@
<j:if test="${hasBuildPermission}">
<div class="icon-container">
<j:if test="${from.isProjectParameterized()}">
<span class="pointer" onclick="buildPipeline.fillDialog('${app.rootUrl}${from.gridBuilder.firstJobLink}/build?delay=0sec', 'Starts the pipeline with parameters')">
<span class="bpp-trigger-pipeline-parameterized pointer" data-fill-dialog-href="${app.rootUrl}${from.gridBuilder.firstJobLink}/build?delay=0sec" data-fill-dialog-title="Starts the pipeline with parameters">
<l:icon src="icon-clock icon-md" alt="Trigger a Pipeline" />
<span>Run</span>
</span>
</j:if>
<j:if test="${!from.isProjectParameterized()}">
<a id="trigger-pipeline-button" href='#' onclick="document.getElementById('triggerPipelineForm').submit()">
<a id="trigger-pipeline-button" href='#'>
<l:icon src="icon-clock icon-md" alt="Trigger a Pipeline" />
<span>Run</span>
</a>
Expand Down Expand Up @@ -131,29 +130,17 @@
<j:forEach begin="${0}" end="${buildPipelineForm.getGridWidth() - 1}" indexVar="y">
<j:set var="build" type="au.com.centrumsystems.hudson.plugin.buildpipeline.BuildForm" value="${buildGrid.get(x,y)}" />
<j:if test="${build != null}">
<td id="build-${build.getId()}"></td>
<script>
// generate build-card
var buildData = ${build.asJSON()};
jQuery("#build-${build.getId()}").append(buildPipeline.buildCardTemplate(buildData));
// add build proxy to proxies for future use
buildPipeline.buildProxies[${build.getId()}] = <st:bind value="${build}" />;
<j:if test="${build.getStatus() == 'BUILDING'}">
buildPipeline.showProgress(${build.getId()}, ${build.getDependencyIds()});
</j:if>
<j:if test="${build.getStatus() == 'PENDING'}">
jQuery("#pipelines").bind("show-status-${build.getId()}", function() {
<j:choose>
<j:when test="${build.isManualTrigger()}">
buildPipeline.updateBuildCard(${build.getId()});
</j:when>
<j:otherwise>
buildPipeline.updateNextBuildAndShowProgress(${build.getId()}, ${build.getNextBuildNumber()}, ${build.getDependencyIds()});
</j:otherwise>
</j:choose>
});
</j:if>
</script>
<td id="build-${build.getId()}">
<j:set var="buildDataJson" value="${build.asJSON()}" />
<span class="build-data"
data-build-id="${build.getId()}"
data-build-info="${buildDataJson}"
data-build-status="${build.getStatus()}"
data-is-manual-trigger="${build.isManualTrigger()}"
data-next-build-number="${build.getNextBuildNumber()}"
data-dependency-ids="${build.getDependencyIds()}"/>
<st:bind var="buildProxy_${build.getId()}" value="${build}" />
</td>
<j:if test="${(y + 1 != buildPipelineForm.getGridWidth())}">
<!-- Changing length to size() to get rid of arrows when there are no more child jobs.-->
<td class="next">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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() {
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);
const dependencyIds = JSON.parse(buildElement.dataset.dependencyIds);

// 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);
}

jQuery("table.pipelines").on(`show-status-${buildId}`, function() {
if (isManualTrigger) {
buildPipeline.updateBuildCard(buildId);
} else {
buildPipeline.updateNextBuildAndShowProgress(
buildId,
nextBuildNumber,
dependencyIds
);
}
});
});
}

document.addEventListener('DOMContentLoaded', initializeBuildCards);
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// show/hide build details
jQuery(document).ready(function() {
jQuery(".header").click(function() {
var parent = jQuery(this).parent();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const buildId = document.querySelector('.pipeline-info .revision .title').dataset.buildId;
jQuery('#build-parameters-trigger-' + buildId).tooltip({
bodyHandler: function() {
return jQuery('#build-parameters-' + buildId).html();
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div class="pipeline-info">
<div class="revision rounded">
<div class="title">Pipeline ${buildGrid.get(0,0).getRevision()}</div>
<div class="title" data-build-id="${buildGrid.get(0,0).getId()}" id="build-parameters-trigger-${buildGrid.get(0,0).getId()}">Pipeline ${buildGrid.get(0,0).getRevision()}</div>
<j:choose>
<j:when test="${buildGrid.get(0,0).getParameters().isEmpty()}">
<div class="description">No parameters</div>
Expand All @@ -21,13 +21,7 @@
</j:forEach>
</ul>
</div>
<script>
jQuery('#build-parameters-trigger-${buildGrid.get(0,0).getId()}').tooltip({
bodyHandler: function() {
return jQuery('#build-parameters-${buildGrid.get(0,0).getId()}').html();
}
});
</script>
<st:adjunct includes="au.com.centrumsystems.hudson.plugin.buildpipeline.extension.AbstractNameValueHeader.build-parameters-tooltip"/>
</j:otherwise>
</j:choose>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
function parseDataAttributes(container) {
return {
id: parseInt(container.dataset.showSpinnerId, 10),
buildExtId: container.dataset.rerunBuildExtId,
dependencyIds: container.dataset.rerunBuildDependencyIds
.split(",")
.filter(Boolean)
.map(id => parseInt(id, 10))
};
}

function parseTriggerAttributes(container) {
return {
id: parseInt(container.dataset.showSpinnerId, 10),
upstreamProjectName: container.dataset.upstreamProjectName,
upstreamBuildNumber: parseInt(container.dataset.upstreamBuildNumber, 10),
projectName: container.dataset.projectName,
dependencyIds: container.dataset.dependencyIds
.split(",")
.filter(Boolean)
.map(id => parseInt(id, 10))
};
}

function handleDialogClick(dataContainer) {
const href = dataContainer.dataset.fillDialogHref;
const title = dataContainer.dataset.fillDialogTitle;
buildPipeline.fillDialog(href, title);
}

function handleRerunClick(dataContainer) {
const { id, buildExtId, dependencyIds } = parseDataAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.rerunBuild(id, buildExtId, dependencyIds);
}

function handleTriggerBuild(dataContainer) {
const { id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds } = parseTriggerAttributes(dataContainer);
buildPipeline.showSpinner(id);
buildPipeline.triggerBuild(id, upstreamProjectName, upstreamBuildNumber, projectName, dependencyIds);
}

function createClickHandler(parentElement, targetSelector, handlerFn) {
const newHandler = function(event) {
const clickTarget = event.target.closest(targetSelector);
if (!clickTarget || !parentElement.contains(clickTarget)) return;

handlerFn(clickTarget);
};

parentElement.addEventListener("click", newHandler);
}

const onclickElements = {
".bct-progress-bar-onclick": {
handler: handleDialogClick
},
".bct-console-icon-onclick": {
handler: handleDialogClick
},
".bct-rerun-successful-build-onclick": {
handler: handleRerunClick
},
".bct-rerun-failed-latest-build-onclick": {
handler: handleRerunClick
},
".bct-rerun-failed-manual-build-onclick": {
handler: handleTriggerBuild
},
".bct-rerun-failed-build-onclick": {
handler: handleRerunClick
},
".bct-trigger-manual-build-latest-onclick": {
handler: handleTriggerBuild
},
".bct-trigger-manual-build-onclick": {
handler: handleTriggerBuild
}
};

document.addEventListener("DOMContentLoaded", function () {
const pipelineWrappers = document.querySelectorAll(".pipeline-wrapper");

if (!pipelineWrappers.length) return;

pipelineWrappers.forEach(wrapper => {
Object.entries(onclickElements).forEach(function([selector, { handler }]) {
createClickHandler(wrapper, selector, handler);
});
});
});
Loading