diff options
| author | Arseney300 <Arseney300@gmail.com> | 2026-02-20 18:35:45 +0700 |
|---|---|---|
| committer | Arseney300 <Arseney300@gmail.com> | 2026-02-20 18:35:45 +0700 |
| commit | fc6afe6c6181fcee7741a4a15edf2a6d55185b7d (patch) | |
| tree | 43df398a3e1795ca3d443030c815e6be9e9fea4c | |
| parent | 4a754b397f887479398ea9e58aa19368ef8e9f8b (diff) | |
Document SCM checkout behavior and large repo settings
Explain that Jenkins auto-clones the repo before running the Jenkinsfile
so a manual checkout stage is unnecessary. Add guidance on configuring
shallow clone and extended timeout for large repositories like the kernel.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| -rw-r--r-- | doc/Jenkinsfile.kernel-example | 9 | ||||
| -rw-r--r-- | doc/jenkins-cpp-build.md | 38 |
2 files changed, 47 insertions, 0 deletions
diff --git a/doc/Jenkinsfile.kernel-example b/doc/Jenkinsfile.kernel-example index f0ed164..92e3f05 100644 --- a/doc/Jenkinsfile.kernel-example +++ b/doc/Jenkinsfile.kernel-example @@ -1,12 +1,21 @@ // Example Jenkinsfile for building the Linux kernel // Uses the custom kernel-builder image (jenkins/kernel-builder/Dockerfile) // Build the image first: docker build -t kernel-builder jenkins/kernel-builder/ +// +// NOTE: When using "Pipeline script from SCM", Jenkins clones the repo +// automatically before running this file. No checkout stage is needed. +// Configure shallow clone + extended timeout in the job's SCM settings +// for large repos (see doc/jenkins-cpp-build.md, section 4). pipeline { agent { docker { image 'kernel-builder' } } + options { + timeout(time: 4, unit: 'HOURS') + } + stages { stage('Build') { steps { diff --git a/doc/jenkins-cpp-build.md b/doc/jenkins-cpp-build.md index d60ffe9..6449ffd 100644 --- a/doc/jenkins-cpp-build.md +++ b/doc/jenkins-cpp-build.md @@ -123,6 +123,44 @@ On the job configuration page: 6. **Script Path**: leave as `Jenkinsfile` (default) 7. Click **Save** +### Large repositories + +For large repos (e.g., the Linux kernel), the default 10-minute fetch timeout +is too short. In the SCM config, click **Additional Behaviours** > **Advanced +clone behaviours** and set: + +- **Fetch tags**: uncheck +- **Timeout (in minutes) for clone and fetch**: `120` (or more) +- **Shallow clone**: check +- **Shallow clone depth**: `1` + +Shallow clone fetches only the latest commit, reducing clone size significantly. + +### Automatic SCM checkout + +When using **Pipeline script from SCM**, Jenkins automatically clones the +repository before running the Jenkinsfile (the "Declarative: Checkout SCM" +step). The workspace already contains the code, so you do **not** need a +`checkout` or `git clone` stage in your Jenkinsfile — adding one would clone +the repo a second time. Just use the files directly in your build stages: + +```groovy +pipeline { + agent { + docker { image 'gcc:latest' } + } + + stages { + stage('Build') { + steps { + // Source code is already in the workspace from SCM checkout + sh 'g++ -o my_app main.cpp' + } + } + } +} +``` + ## 5. Run the build |
