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

Define pipeline jobs using JCasC and Job DSL #324

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
52 changes: 9 additions & 43 deletions hosts/azure/jenkins-controller/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -137,45 +137,6 @@ in
# Increase the number of rows shown in Stage View (default is 10)
"-Dcom.cloudbees.workflow.rest.external.JobExt.maxRunsPerJob=32"
];

# Configure jenkins job(s):
# https://jenkins-job-builder.readthedocs.io/en/latest/project_pipeline.html
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/continuous-integration/jenkins/job-builder.nix
jobBuilder = {
enable = true;
nixJobs =
lib.mapAttrsToList
(display-name: script: {
job = {
inherit display-name;
name = script;
project-type = "pipeline";
concurrent = true;
mkaapu marked this conversation as resolved.
Show resolved Hide resolved
pipeline-scm = {
script-path = "${script}.groovy";
lightweight-checkout = true;
scm = [
{
git = {
url = "https://github.com/tiiuae/ghaf-jenkins-pipeline.git";
clean = true;
branches = [ "*/main" ];
};
}
];
};
};
})
{
"Ghaf main pipeline" = "ghaf-main-pipeline";
"Ghaf pre-merge pipeline" = "ghaf-pre-merge-pipeline";
"Ghaf nightly pipeline" = "ghaf-nightly-pipeline";
"Ghaf release pipeline" = "ghaf-release-pipeline";
"Ghaf HW test" = "ghaf-hw-test";
"Ghaf parallel HW test" = "ghaf-parallel-hw-test";
"FMO OS main pipeline" = "fmo-os-main-pipeline";
};
};
};

systemd.services.jenkins.serviceConfig = {
Expand Down Expand Up @@ -230,10 +191,15 @@ in
''
# Install plugins
jenkins-cli ${jenkins-auth} install-plugin \
"workflow-aggregator" "github" "timestamper" "pipeline-stage-view" "blueocean" \
"pipeline-graph-view" "github-pullrequest" "antisamy-markup-formatter" \
"configuration-as-code" "slack" "pipeline-utility-steps" "pipeline-build-step" \
"robot" "copyartifact"
"configuration-as-code" "job-dsl" \
"workflow-aggregator" "pipeline-utility-steps" "pipeline-build-step" \
"github" "github-pullrequest" \
"blueocean" "pipeline-stage-view" "pipeline-graph-view" \
"timestamper" \
"antisamy-markup-formatter" \
"slack" \
"robot" \
"copyartifact"

# Disable initial install
jenkins-cli ${jenkins-auth} groovy = < ${jenkins-groovy}
Expand Down
160 changes: 160 additions & 0 deletions hosts/azure/jenkins-controller/jenkins-casc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,163 @@ tool:
mavenGlobalConfig:
globalSettingsProvider: "standard"
settingsProvider: "standard"
# https://github.com/jenkinsci/job-dsl-plugin
# https://jenkinsci.github.io/job-dsl-plugin
jobs:
- script: >
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lot of duplication in here. Can we keep this generated by Nix, and call a helper function with the different arguments for things that differ?

pipelineJob('ghaf-main-pipeline') {
displayName('Ghaf main pipeline')
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/tiiuae/ghaf-jenkins-pipeline.git')
}
branch('*/main')
extensions {
cleanBeforeCheckout()
}
}
scriptPath('ghaf-main-pipeline.groovy')
}
lightweight()
}
}
}
- script: >
pipelineJob('ghaf-pre-merge-pipeline') {
displayName('Ghaf pre-merge pipeline')
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/tiiuae/ghaf-jenkins-pipeline.git')
}
branch('*/main')
extensions {
cleanBeforeCheckout()
}
}
scriptPath('ghaf-pre-merge-pipeline.groovy')
}
lightweight()
}
}
}
- script: >
pipelineJob('ghaf-nightly-pipeline') {
displayName('Ghaf nightly pipeline')
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/tiiuae/ghaf-jenkins-pipeline.git')
}
branch('*/main')
extensions {
cleanBeforeCheckout()
}
}
scriptPath('ghaf-nightly-pipeline.groovy')
}
lightweight()
}
}
}
- script: >
pipelineJob('ghaf-release-pipeline') {
displayName('Ghaf release pipeline')
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/tiiuae/ghaf-jenkins-pipeline.git')
}
branch('*/main')
extensions {
cleanBeforeCheckout()
}
}
scriptPath('ghaf-release-pipeline.groovy')
}
lightweight()
}
}
}
- script: >
pipelineJob('ghaf-hw-test') {
displayName('Ghaf HW test')
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/tiiuae/ghaf-jenkins-pipeline.git')
}
branch('*/main')
extensions {
cleanBeforeCheckout()
}
}
scriptPath('ghaf-hw-test.groovy')
}
lightweight()
}
}
}
- script: >
pipelineJob('ghaf-parallel-hw-test') {
displayName('Ghaf parallel HW test')
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/tiiuae/ghaf-jenkins-pipeline.git')
}
branch('*/main')
extensions {
cleanBeforeCheckout()
}
}
scriptPath('ghaf-parallel-hw-test.groovy')
}
lightweight()
}
}
}
- script: >
pipelineJob('fmo-os-main-pipeline') {
displayName('FMO OS main_pipeline')
definition {
cpsScm {
scm {
git {
remote {
url('https://github.com/tiiuae/ghaf-jenkins-pipeline.git')
}
branch('*/main')
extensions {
cleanBeforeCheckout()
}
}
scriptPath('fmo-os-main-pipeline.groovy')
}
lightweight()
}
}
}
- script: >
queue('ghaf-main-pipeline')
- script: >
queue('ghaf-pre-merge-pipeline')
- script: >
queue('ghaf-nightly-pipeline')
- script: >
queue('ghaf-release-pipeline')
- script: >
queue('fmo-os-main-pipeline')
Loading