summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordd <dd@wx.tnyzeq.icu>2024-06-30 16:56:57 +0200
committerdd <dd@wx.tnyzeq.icu>2024-06-30 16:56:57 +0200
commit0cd2d6f160faf45d872aa169ae7a1d93adffc114 (patch)
tree64283fbe477cc5b75e75169d6ea55d2e281717b8
parent361f1909f81aedeaa5d4a44d6dc6287ac4017f8d (diff)
downloadvyos-jenkins-0cd2d6f160faf45d872aa169ae7a1d93adffc114.tar.gz
vyos-jenkins-0cd2d6f160faf45d872aa169ae7a1d93adffc114.zip
updated seed-jobs to use shared job jsons
-rw-r--r--manual/jobs.json450
-rwxr-xr-xmanual/seed-jobs.sh100
-rw-r--r--readme.md4
3 files changed, 53 insertions, 501 deletions
diff --git a/manual/jobs.json b/manual/jobs.json
deleted file mode 100644
index 2605b96..0000000
--- a/manual/jobs.json
+++ /dev/null
@@ -1,450 +0,0 @@
-[
- {
- "name": "aws-gateway-load-balancer-tunnel-handler",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/aws-gateway-load-balancer-tunnel-handler/Jenkinsfile"
- },
- {
- "name": "ddclient",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/ddclient/Jenkinsfile"
- },
- {
- "name": "dropbear",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/dropbear/Jenkinsfile"
- },
- {
- "name": "ethtool",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/ethtool/Jenkinsfile"
- },
- {
- "name": "frr",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/frr/Jenkinsfile"
- },
- {
- "name": "hostap",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/hostap/Jenkinsfile"
- },
- {
- "name": "hsflowd",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/hsflowd/Jenkinsfile"
- },
- {
- "name": "hvinfo",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/hvinfo.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "ipaddrcheck",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/ipaddrcheck.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "iproute2",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "equuleus",
- "jenkinsfilePath": "packages/iproute2/Jenkinsfile"
- },
- {
- "name": "isc-dhcp",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/isc-dhcp/Jenkinsfile"
- },
- {
- "name": "keepalived",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/keepalived/Jenkinsfile"
- },
- {
- "name": "libnss-mapuser",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/libnss-mapuser.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "libnss-tacplus",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/dd010101/vyos-missing.git",
- "branchRegex": "(sagitta)",
- "jenkinsfilePath": "packages/libnss-tacplus/Jenkinsfile"
- },
- {
- "name": "libpam-radius-auth",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/libpam-radius-auth.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "libvyosconfig",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/libvyosconfig.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "linux-kernel",
- "description": "shared",
- "gitUrl": "https://github.com/dd010101/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/linux-kernel/Jenkinsfile"
- },
- {
- "name": "live-boot",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/live-boot.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "mdns-repeater",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/mdns-repeater.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "minisign",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "equuleus",
- "jenkinsfilePath": "packages/minisign/Jenkinsfile"
- },
- {
- "name": "ndppd",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/ndppd/Jenkinsfile"
- },
- {
- "name": "netfilter",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/netfilter/Jenkinsfile"
- },
- {
- "name": "ocserv",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "equuleus",
- "jenkinsfilePath": "packages/ocserv/Jenkinsfile"
- },
- {
- "name": "opennhrp",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/opennhrp/Jenkinsfile"
- },
- {
- "name": "openvpn-otp",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/openvpn-otp/Jenkinsfile"
- },
- {
- "name": "owamp",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/owamp/Jenkinsfile"
- },
- {
- "name": "pam_tacplus",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/dd010101/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/pam_tacplus/Jenkinsfile"
- },
- {
- "name": "pmacct",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/pmacct/Jenkinsfile"
- },
- {
- "name": "pyhumps",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/pyhumps/Jenkinsfile"
- },
- {
- "name": "python3-inotify",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/dd010101/vyos-missing.git",
- "branchRegex": "equuleus",
- "jenkinsfilePath": "packages/python3-inotify/Jenkinsfile"
- },
- {
- "name": "radvd",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/radvd/Jenkinsfile"
- },
- {
- "name": "strongswan",
- "description": "sagitta-only",
- "gitUrl": "https://github.com/dd010101/vyos-build.git",
- "branchRegex": "sagitta",
- "jenkinsfilePath": "packages/strongswan/Jenkinsfile"
- },
- {
- "name": "telegraf",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/telegraf/Jenkinsfile"
- },
- {
- "name": "udp-broadcast-relay",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/udp-broadcast-relay.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-bash",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyatta-bash.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-biosdevname",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyatta-biosdevname.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-cfg-firewall",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-cfg-firewall.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-cfg-qos",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-cfg-qos.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-cfg-quagga",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-cfg-quagga.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-cfg-system",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyatta-cfg-system.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-cfg-vpn",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-cfg-vpn.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-cfg",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyatta-cfg.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-cluster",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-cluster.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-config-mgmt",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-config-mgmt.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-conntrack",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-conntrack.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-nat",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-nat.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-op-firewall",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-op-firewall.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-op-qos",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-op-qos.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-op-vpn",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-op-vpn.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-op",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyatta-op.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-wanloadbalance",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyatta-wanloadbalance.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyatta-zone",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyatta-zone.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-1x",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-1x.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-cloud-init",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-cloud-init.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-http-api-tools",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-http-api-tools.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-nhrp",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyos-nhrp.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-opennhrp",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyos-opennhrp.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-strongswan",
- "description": "equuleus-only",
- "gitUrl": "https://github.com/vyos/vyos-strongswan.git",
- "branchRegex": "(equuleus)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-user-utils",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-user-utils.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-utils",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-utils.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-world",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-world.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-xe-guest-utilities",
- "description": "shared",
- "gitUrl": "https://github.com/vyos/vyos-xe-guest-utilities.git",
- "branchRegex": "(equuleus|current)",
- "jenkinsfilePath": "Jenkinsfile"
- },
- {
- "name": "vyos-build-container",
- "description": "shared",
- "gitUrl": "https://github.com/dd010101/vyos-build.git",
- "branchRegex": "(equuleus|sagitta|current)",
- "jenkinsfilePath": "packages/vyos-build-container/Jenkinsfile"
- },
- {
- "name": "wide-dhcpv6",
- "description": "shared",
- "gitUrl": "https://github.com/dd010101/vyos-build.git",
- "branchRegex": "(equuleus|sagitta)",
- "jenkinsfilePath": "packages/wide-dhcpv6/Jenkinsfile"
- }
-]
diff --git a/manual/seed-jobs.sh b/manual/seed-jobs.sh
index 0d20ccc..2cf488b 100755
--- a/manual/seed-jobs.sh
+++ b/manual/seed-jobs.sh
@@ -35,6 +35,8 @@ workDir="/tmp/seed-jobs"
mkdir -p "$workDir"
templatePath="../jobs/jobTemplate.xml"
+dockerContainerJobsPath="../jobs/docker-container-jobs.json"
+projectsJobsPath="../jobs/project-jobs.json"
jenkinsUser=${jenkinsUser:-$JENKINS_USER}
jenkinsToken=${jenkinsToken:-$JENKINS_TOKEN}
jenkinsUrl="http://${jenkinsUser}:${jenkinsToken}@$jenkinsHost"
@@ -43,15 +45,15 @@ mode="$1"
availableModes=("create" "build")
get() {
- curl -sS -g --fail-with-body "${jenkinsUrl}${1}"
+ curl -sS -g --fail-with-body "${jenkinsUrl}${1}"
}
post() {
- curl -sS -g --fail-with-body -X POST "${jenkinsUrl}${1}"
+ curl -sS -g --fail-with-body -X POST "${jenkinsUrl}${1}"
}
push() {
- curl -sS -g --fail-with-body -X POST -d "@${2}" -H "Content-Type: text/xml" "${jenkinsUrl}${1}"
+ curl -sS -g --fail-with-body -X POST -d "@${2}" -H "Content-Type: text/xml" "${jenkinsUrl}${1}"
}
echo -n "testing jenkins connection: "
@@ -59,58 +61,60 @@ get > /dev/null
echo "ok"
if [[ "$mode" == "create" ]]; then
- while read item
- do
- jobName=$(echo "$item" | jq -r .name)
- echo -n "$jobName:"
-
- description=$(echo "$item" | jq -r .description)
- gitUrl=$(echo "$item" | jq -r .gitUrl)
- branchRegex=$(echo "$item" | jq -r .branchRegex)
- jenkinsfilePath=$(echo "$item" | jq -r .jenkinsfilePath)
-
- # create job.xml by using jobTemplate.xml
- jobPath="$workDir/$jobName.xml"
- project="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject"
- branchSource="$project/sources/data/jenkins.branch.BranchSource/source"
- regexTrait="$branchSource/traits/jenkins.scm.impl.trait.RegexSCMHeadFilterTrait"
- xmlstarlet ed --update "//$project/description" --value "$description" \
- --update "//$branchSource/remote" --value "$gitUrl" \
- --update "//$regexTrait/regex" --value "$branchRegex" \
- --update "//$project/factory/scriptPath" --value "$jenkinsfilePath" \
- "$templatePath" > "$jobPath" 2>/dev/null
-
- # check if job exists
- result=$(get "/checkJobName?value=$jobName" || true)
- if [[ "$result" == *"already exists"* ]]; then
- # update job
- push "/job/$jobName/config.xml" "$jobPath"
- else
- # create job
- push "/createItem?name=$jobName" "$jobPath"
- fi
-
- echo " ok"
-
- done < <(cat jobs.json | jq -c '.[]')
+ jobsPath="$workDir/jobs.json"
+ cat "$dockerContainerJobsPath" "$projectsJobsPath" | jq -s 'add' > "$jobsPath"
+
+ while read item
+ do
+ jobName=$(echo "$item" | jq -r .name)
+ echo -n "$jobName:"
+
+ description=$(echo "$item" | jq -r .description)
+ gitUrl=$(echo "$item" | jq -r .gitUrl)
+ branchRegex=$(echo "$item" | jq -r .branchRegex)
+ jenkinsfilePath=$(echo "$item" | jq -r .jenkinsfilePath)
+
+ # create job.xml by using jobTemplate.xml
+ jobPath="$workDir/$jobName.xml"
+ project="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject"
+ branchSource="$project/sources/data/jenkins.branch.BranchSource/source"
+ regexTrait="$branchSource/traits/jenkins.scm.impl.trait.RegexSCMHeadFilterTrait"
+ xmlstarlet ed --update "//$project/description" --value "$description" \
+ --update "//$branchSource/remote" --value "$gitUrl" \
+ --update "//$regexTrait/regex" --value "$branchRegex" \
+ --update "//$project/factory/scriptPath" --value "$jenkinsfilePath" \
+ "$templatePath" > "$jobPath" 2>/dev/null
+
+ # check if job exists
+ result=$(get "/checkJobName?value=$jobName" || true)
+ if [[ "$result" == *"already exists"* ]]; then
+ # update job
+ push "/job/$jobName/config.xml" "$jobPath"
+ else
+ # create job
+ push "/createItem?name=$jobName" "$jobPath"
+ fi
+
+ echo " ok"
+ done < <(cat "$jobsPath" | jq -c '.[]')
elif [[ "$mode" == "build" ]]; then
- get "/api/xml?tree=jobs[name]" | xmlstarlet sel -t -v "//hudson/job/name" | while read jobName || [ -n "$jobName" ]; do
+ get "/api/xml?tree=jobs[name]" | xmlstarlet sel -t -v "//hudson/job/name" | while read jobName || [ -n "$jobName" ]; do
- echo -n "$jobName:"
+ echo -n "$jobName:"
- # trigger build - it's not easy to know what branches job has
- # thus we trigger all possible ones and ignore not found
- post "/job/$jobName/job/equuleus/build" > /dev/null 2>/dev/null || true
- post "/job/$jobName/job/sagitta/build" > /dev/null 2>/dev/null || true
- post "/job/$jobName/job/current/build" > /dev/null 2>/dev/null || true
+ # trigger build - it's not easy to know what branches job has
+ # thus we trigger all possible ones and ignore not found
+ post "/job/$jobName/job/equuleus/build" > /dev/null 2>/dev/null || true
+ post "/job/$jobName/job/sagitta/build" > /dev/null 2>/dev/null || true
+ post "/job/$jobName/job/current/build" > /dev/null 2>/dev/null || true
- echo " ok"
+ echo " ok"
- done
+ done
else
- echo "ERROR: unknown mode '$mode'"
- echo "available modes: ${availableModes[*]}"
+ echo "ERROR: unknown mode '$mode'"
+ echo "available modes: ${availableModes[*]}"
fi
diff --git a/readme.md b/readme.md
index bc5956c..0930acb 100644
--- a/readme.md
+++ b/readme.md
@@ -579,9 +579,7 @@ Script exists to automate pipeline/job creation.
> **Name:** CLI\
> -> [Generate] -> [copy generated key and save it for later use]
-**Get the script seed-jobs.sh**
-
-And its assets (jobs.json, jobTemplate.xml).
+**Get the script**
```bash
git clone https://github.com/dd010101/vyos-jenkins.git