laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ci/+/42099?usp=email )

Change subject: jobs/build-kernels-testenv: use linux-shallow-clone
......................................................................

jobs/build-kernels-testenv: use linux-shallow-clone

Related: OS#6938
Change-Id: I8cb2acfaf585b9f92347a4562525a66ed03b0236
---
M jobs/build-kernels-testenv.yml
M scripts/kernel/build.sh
2 files changed, 33 insertions(+), 47 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/jobs/build-kernels-testenv.yml b/jobs/build-kernels-testenv.yml
index 47a9dd9..cfbc244 100644
--- a/jobs/build-kernels-testenv.yml
+++ b/jobs/build-kernels-testenv.yml
@@ -1,69 +1,45 @@
 ---
 - project:
     name: 'build-kernels'
-    concurrent: false
-    description: |
-        Build kernels to be used with osmo-ttcn3-hacks to run SUT in QEMU.<br>
-        <br>
-        Git repository:<br>
-        <code>{url}</code><br>
-        <br>
-        Branch:<br>
-        <code>{branch}</code><br>
     jobs:
-      - "{job-name}"
-    branch: master
-    job-name:
-      - build-kernel-net-next:
-          url: 
"https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git";
-          branch: main
-      - build-kernel-torvalds:
-          url: 
"https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git";
+      - 'build-kernel-{linux-repo}'
+    linux-repo:
+      - torvalds:
+          linux-branch: "master"
+      - net-next:
+          linux-branch: "main"

 - job-template:
-    name: '{job-name}'
+    name: 'build-kernel-{linux-repo}'
     project-type: freestyle
-    defaults: global
-    description: '{obj:description}'
-    # Limit to 1 node to save space on others
-    node: "build4-deb12build-ansible"
-    concurrent: false
+    description: |
+        Build a <code>{linux-repo}/{linux-branch}</code> kernel to be used with
+        osmo-ttcn3-hacks for running SUT in QEMU
+    node: "linux-shallow-clone"
+    concurrent: true
     parameters:
       - string:
           name: EMAIL_NOTIFICATIONS
           description: For failed build notifications, set to empty to disable
           default: '[email protected]'
       - string:
-          name: BRANCH_KERNEL
-          description: Branch of the kernel repository
-          default: '{branch}'
-      - string:
           name: BRANCH_CI
           description: Branch of osmo-ci.git (has scripts/kernel/build.sh)
           default: 'master'
     builders:
       - shell: |-
-          git config gc.autoDetach false
-          git gc --auto
-
+          set -e
           IMAGE="osmocom-build/debian-bookworm-osmo-ttcn3-testenv"
           podman pull "registry.osmocom.org/$IMAGE"
-
-          rm -rf output osmo-ci
-          git clone --depth=1 https://gerrit.osmocom.org/osmo-ci -b 
"$BRANCH_CI"
-          osmo-ci/scripts/kernel/build.sh
+          scripts/kernel/build.sh ~/linux.git {linux-repo}-{linux-branch}
     scm:
       - git:
           branches:
-            - '$BRANCH_KERNEL'
-          url: "{obj:url}"
+            - '$BRANCH_CI'
+          url: "https://gerrit.osmocom.org/osmo-ci";
           git-config-name: 'Jenkins Builder'
           git-config-email: '[email protected]'
-          refspec: 
'+refs/heads/$BRANCH_KERNEL:refs/remotes/origin/$BRANCH_KERNEL'
-          shallow-clone: true
-          wipe-workspace: false
-          clean:
-            before: true
+          wipe-workspace: true
     triggers:
       - timed: "H 23 * * *"
     publishers:
diff --git a/scripts/kernel/build.sh b/scripts/kernel/build.sh
index cc69a0d..f1a1e0a 100755
--- a/scripts/kernel/build.sh
+++ b/scripts/kernel/build.sh
@@ -1,19 +1,29 @@
 #!/bin/sh -ex
 IMAGE="debian-bookworm-osmo-ttcn3-testenv"
 SCRIPT_DIR="$(realpath "$(dirname "$0")")"
+LINUX_GIT_DIR="$1"
+LINUX_REPO_BRANCH="$2"
+
+test -d "$LINUX_GIT_DIR"
+test -n "$LINUX_REPO_BRANCH"

 mkdir -p output

 podman run \
        --rm \
+       -v "$LINUX_GIT_DIR:/linux.git:ro" \
        -v "$SCRIPT_DIR:/scripts/kernel/" \
-       -v "$PWD:$PWD" \
-       -w "$PWD" \
+       -v "$PWD/output:/output" \
        "$IMAGE" \
-       timeout 3h sh -exc '
+       timeout 3h sh -exc "
+               git config --global --add safe.directory /linux.git
+               git -C /linux.git log -1 --oneline $LINUX_REPO_BRANCH
+               git clone -q /linux.git -b $LINUX_REPO_BRANCH /linux
+               cd /linux
+
                make defconfig
                scripts/kconfig/merge_config.sh -m .config 
/scripts/kernel/fragment.config
                make olddefconfig
-               make "-j$(nproc)"
-               cp arch/x86/boot/bzImage output/linux
-       ' | tee output/build.log
+               make -j$(nproc)
+               cp arch/x86/boot/bzImage /output/linux
+       " | tee output/build.log

--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/42099?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I8cb2acfaf585b9f92347a4562525a66ed03b0236
Gerrit-Change-Number: 42099
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to