-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathJenkinsfile
More file actions
114 lines (101 loc) · 3.05 KB
/
Jenkinsfile
File metadata and controls
114 lines (101 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
pipeline {
agent none
options {
timestamps()
skipDefaultCheckout(true)
parallelsAlwaysFailFast()
}
parameters {
string(name: 'PR_NUMBER', defaultValue: '', description: 'Pull request number, optional')
string(name: 'BRANCH_NAME', defaultValue: 'main', description: 'Branch to build')
string(name: 'GIT_COMMIT', defaultValue: '', description: 'Commit SHA to build, optional')
string(name: 'REPO_URL', defaultValue: 'https://github.com/star-bnl/star-sw.git', description: 'Repository URL')
}
environment {
ARTIFACT_DIR = 'artifacts'
}
stages {
stage('Build Docker Images') {
matrix {
agent any
axes {
axis {
name 'STAR_BASE'
values 'root5', 'root6'
}
axis {
name 'COMPILER'
values 'gcc485', 'gcc11'
}
}
stages {
stage('Checkout') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: "*/${params.BRANCH_NAME}"]],
userRemoteConfigs: [[
url: "${params.REPO_URL}",
refspec: '+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*'
]]
])
}
}
stage('Checkout exact commit if provided') {
when {
expression { return params.GIT_COMMIT?.trim() }
}
steps {
sh '''
set -euxo pipefail
git fetch --all --tags
git checkout "${GIT_COMMIT}"
git rev-parse HEAD
'''
}
}
stage('Prepare Docker Buildx') {
steps {
sh '''
set -euxo pipefail
command -v docker
docker --version
docker buildx version
docker buildx use default || true
docker buildx inspect default --bootstrap || docker buildx inspect --bootstrap
'''
}
}
stage('Build Docker Image') {
steps {
sh '''
set -euxo pipefail
starenv="${STAR_BASE}-${COMPILER}"
image_tag="ghcr.io/star-bnl/star-sw-${starenv}"
image_tar="${ARTIFACT_DIR}/star-sw-${starenv}.tar"
mkdir -p "${ARTIFACT_DIR}"
docker buildx build \
--progress plain \
--build-arg "starenv=${STAR_BASE}" \
--build-arg "compiler=${COMPILER}" \
--tag "${image_tag}" \
--output "type=docker,dest=${image_tar}" \
.
'''
}
}
stage('Archive Docker Image') {
steps {
archiveArtifacts artifacts: "artifacts/star-sw-${STAR_BASE}-${COMPILER}.tar", fingerprint: true
}
}
}
}
}
}
post {
always {
echo "Build finished: ${currentBuild.currentResult}"
}
}
}