jenkins: fix dark theme injection

This commit is contained in:
Brad Stein 2026-01-20 18:13:49 -03:00
parent c846d2c1ba
commit 0bb45bca83

View File

@ -1,21 +1,46 @@
import jenkins.model.Jenkins import jenkins.model.Jenkins
import org.codefirst.SimpleThemeDecorator import org.codefirst.SimpleThemeDecorator
import org.jenkinsci.plugins.simpletheme.CssTextThemeElement
def instance = Jenkins.get() def instance = Jenkins.get()
def decorators = instance.getExtensionList(SimpleThemeDecorator.class) def decorators = instance.getExtensionList(SimpleThemeDecorator.class)
if (decorators?.size() > 0) { if (decorators?.size() > 0) {
def theme = decorators[0] def theme = decorators[0]
theme.setCssUrl("https://cdn.jsdelivr.net/gh/Jorg3Lucas/jenkins-modern-themes@main/dist/modern-blue-grey.css") def cssRules = """
theme.setCssRules(""" :root,
:root { .app-theme-picker__picker[data-theme=none] {
--atlas-bg: #0f1216; --background: #0f1216 !important;
--atlas-surface: #171b21; --header-background: #141922 !important;
--atlas-surface-alt: #1f252d; --header-border: #2b313b !important;
--atlas-border: #2b313b; --white: #141922 !important;
--atlas-text: #e6e9ef; --black: #e6e9ef !important;
--atlas-text-muted: #b3bac6; --very-light-grey: #171b21 !important;
--atlas-link: #8fb7ff; --light-grey: #202734 !important;
--medium-grey: #2b313b !important;
--dark-grey: #0b0f14 !important;
--text-color: #e6e9ef !important;
--text-color-secondary: #a6adba !important;
--card-background: #171b21 !important;
--card-border-color: #2b313b !important;
--pane-header-bg: #1f252d !important;
--pane-header-border-color: #2b313b !important;
--pane-border-color: #2b313b !important;
--pane-text-color: #e6e9ef !important;
--pane-header-text-color: #e6e9ef !important;
--link-color: #8fb7ff !important;
--link-color--hover: #b0ccff !important;
--link-dark-color: #e6e9ef !important;
--link-dark-color--hover: #b0ccff !important;
--input-color: #151a20 !important;
--input-border: #2b313b !important;
--input-border-hover: #3a424d !important;
--button-background: #232a33 !important;
--button-background--hover: #2b313b !important;
--button-background--active: #323b46 !important;
--item-background--hover: #232a33 !important;
--item-background--active: #2b313b !important;
--accent-color: #8fb7ff !important;
} }
body, body,
@ -29,83 +54,84 @@ body,
.bottom-sticker-inner, .bottom-sticker-inner,
#breadcrumbBar, #breadcrumbBar,
#breadcrumbs { #breadcrumbs {
background-color: var(--atlas-bg) !important; background-color: var(--background) !important;
color: var(--atlas-text) !important; color: var(--text-color) !important;
} }
#side-panel .task-link, .jenkins-card,
#breadcrumbs a, .jenkins-section,
#breadcrumbs, .jenkins-section__item,
#projectstatus th a, #main-panel .jenkins-card,
#main-panel .jenkins-section {
background-color: var(--card-background) !important;
color: var(--text-color) !important;
border-color: var(--card-border-color) !important;
}
table.pane,
table.pane td,
table.pane th,
#projectstatus td, #projectstatus td,
#projectstatus th { #projectstatus th {
color: var(--atlas-text-muted) !important; background-color: var(--card-background) !important;
} color: var(--text-color) !important;
a,
a:visited,
a:link {
color: var(--atlas-link) !important;
}
a:hover {
opacity: 0.85;
}
#main-panel,
#main-panel-content,
#description,
.pane,
table.pane {
background-color: var(--atlas-surface) !important;
color: var(--atlas-text) !important;
}
table.pane tr:nth-child(odd) td {
background-color: var(--atlas-surface) !important;
} }
table.pane tr:nth-child(even) td, table.pane tr:nth-child(even) td,
#projectstatus tr:hover td { #projectstatus tr:hover td {
background-color: var(--atlas-surface-alt) !important; background-color: #1f252d !important;
} }
input, input,
select, select,
textarea, textarea,
#search-box { #search-box {
background-color: var(--atlas-surface-alt) !important; background-color: #151a20 !important;
color: var(--atlas-text) !important; color: var(--text-color) !important;
border-color: var(--atlas-border) !important; border-color: var(--input-border) !important;
} }
#header, a,
#page-header { a:visited,
background-color: #202734 !important; a:link {
color: var(--link-color) !important;
} }
#header .login, a:hover {
#page-header .login { opacity: 0.85;
color: var(--atlas-text) !important;
} }
#side-panel .task-link, #side-panel .task-link,
#side-panel .task-link:visited, #breadcrumbs a,
#side-panel .task-link:hover { #breadcrumbs,
color: var(--atlas-text) !important; #projectstatus th a {
color: var(--text-color-secondary) !important;
}
.console-output,
.console-output pre,
pre,
code,
.CodeMirror {
background-color: #0c0f14 !important;
color: #d9dee7 !important;
} }
#footer { #footer {
background-color: var(--atlas-bg) !important; background-color: var(--background) !important;
color: var(--atlas-text-muted) !important; color: var(--text-color-secondary) !important;
} }
.jenkins_ver:after { .jenkins_ver:after {
content: "atlas dark"; content: "atlas dark";
} }
""".stripIndent().trim()) """.stripIndent().trim()
theme.setElements([new CssTextThemeElement(cssRules)])
theme.setCssUrl("")
theme.setCssRules(cssRules)
theme.setJsUrl("") theme.setJsUrl("")
instance.save() theme.save()
println("Applied simple-theme-plugin dark theme") println("Applied simple-theme-plugin dark theme")
} else { } else {
println("simple-theme-plugin not installed; skipping theme configuration") println("simple-theme-plugin not installed; skipping theme configuration")