summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseney300 <Arseney300@gmail.com>2026-02-20 11:20:35 +0700
committerArseney300 <Arseney300@gmail.com>2026-02-20 11:20:35 +0700
commit68d5770c626dcad4f8e116a8b984d16458c557b6 (patch)
treee993f9072dfec0d0f359da53bfa6e96dfc509117
parent5a39cbfef6e4b613b39039896a565f173d137bcd (diff)
Add build artifacts section to Jenkins C++ build guide
Explain that Docker build containers are ephemeral and show how to use archiveArtifacts to persist compiled binaries in Jenkins storage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
-rw-r--r--doc/jenkins-cpp-build.md86
1 files changed, 85 insertions, 1 deletions
diff --git a/doc/jenkins-cpp-build.md b/doc/jenkins-cpp-build.md
index 31d88e2..d60ffe9 100644
--- a/doc/jenkins-cpp-build.md
+++ b/doc/jenkins-cpp-build.md
@@ -137,8 +137,92 @@ You will see Jenkins:
- Run each stage (`Build`, `Test`)
- Destroy the container when done
+**Important:** The build container is ephemeral — everything inside it
+(including compiled binaries) is destroyed when the pipeline finishes.
+To keep build artifacts, see the next section.
-## 6. Automatic builds (optional)
+
+## 6. Saving build artifacts
+
+By default the Docker build container is destroyed after the pipeline runs,
+taking all compiled binaries with it. Use `archiveArtifacts` to copy files
+into Jenkins' permanent storage before the container is removed.
+
+### Simple build with artifacts
+
+```groovy
+pipeline {
+ agent {
+ docker { image 'gcc:latest' }
+ }
+
+ stages {
+ stage('Build') {
+ steps {
+ sh 'g++ -o my_app main.cpp'
+ }
+ }
+
+ stage('Test') {
+ steps {
+ sh './my_app'
+ }
+ }
+
+ stage('Archive') {
+ steps {
+ archiveArtifacts artifacts: 'my_app', fingerprint: true
+ }
+ }
+ }
+}
+```
+
+### CMake build with artifacts
+
+```groovy
+pipeline {
+ agent {
+ docker { image 'gcc:latest' }
+ }
+
+ stages {
+ stage('Configure') {
+ steps {
+ sh 'cmake -B build -S .'
+ }
+ }
+
+ stage('Build') {
+ steps {
+ sh 'cmake --build build'
+ }
+ }
+
+ stage('Test') {
+ steps {
+ sh 'cd build && ctest --output-on-failure'
+ }
+ }
+
+ stage('Archive') {
+ steps {
+ archiveArtifacts artifacts: 'build/my_app', fingerprint: true
+ }
+ }
+ }
+}
+```
+
+Archived files are stored in `/var/jenkins_home/jobs/<job>/builds/<number>/archive/`
+and can be downloaded from the build page in the Jenkins web UI under **Build Artifacts**.
+
+You can use glob patterns to archive multiple files, e.g.:
+- `archiveArtifacts artifacts: 'build/**/*.so'` — all shared libraries
+- `archiveArtifacts artifacts: 'build/bin/*'` — everything in a bin directory
+
+
+## 7. Automatic builds (optional)
### Option A — Poll SCM