@@ -92,34 +92,34 @@ j_url=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${j_vrs
92
92
93
93
# Make or Clean WORKSPACE
94
94
if [[ -d " ${workspace} " ]]; then
95
- rm -rf " ${workspace} /Dockerfile" \
96
- " ${workspace} /docker-jenkins" \
97
- " ${workspace} /plugins.*" \
98
- " ${workspace} /install-plugins.sh" \
99
- " ${workspace} /jenkins.sh" \
100
- " ${workspace} /jenkins-support" \
101
- " ${workspace} /init.groovy"
95
+ rm -rf " ${workspace} /Dockerfile" \
96
+ " ${workspace} /docker-jenkins" \
97
+ " ${workspace} /plugins.*" \
98
+ " ${workspace} /install-plugins.sh" \
99
+ " ${workspace} /jenkins.sh" \
100
+ " ${workspace} /jenkins-support" \
101
+ " ${workspace} /init.groovy"
102
102
else
103
- mkdir -p " ${workspace} "
103
+ mkdir -p " ${workspace} "
104
104
fi
105
105
106
106
# Determine the prefix of the Dockerfile's base image
107
107
case ${ARCH} in
108
- " ppc64le" )
109
- docker_base=" ppc64le/"
110
- tini_arch=" ppc64el"
111
- ;;
112
- " x86_64" )
113
- docker_base=" "
114
- tini_arch=" amd64"
115
- ;;
116
- " aarch64" )
117
- docker_base=" arm64v8/"
118
- tini_arch=" arm64"
119
- ;;
120
- * )
121
- echo " Unsupported system architecture(${ARCH} ) found for docker image"
122
- exit 1
108
+ " ppc64le" )
109
+ docker_base=" ppc64le/"
110
+ tini_arch=" ppc64el"
111
+ ;;
112
+ " x86_64" )
113
+ docker_base=" "
114
+ tini_arch=" amd64"
115
+ ;;
116
+ " aarch64" )
117
+ docker_base=" arm64v8/"
118
+ tini_arch=" arm64"
119
+ ;;
120
+ * )
121
+ echo " Unsupported system architecture(${ARCH} ) found for docker image"
122
+ exit 1
123
123
esac
124
124
125
125
# Move Into the WORKSPACE
@@ -208,60 +208,60 @@ docker build -t "${img_name}" .
208
208
209
209
if [[ " ${launch} " == " docker" ]]; then
210
210
211
- # Ensure directories that will be mounted exist
212
- if [[ -n " ${host_import_mnt} " && ! -d " ${host_import_mnt} " ]]; then
213
- mkdir -p " ${host_import_mnt} "
214
- fi
215
-
216
- if [[ ! -d " ${home_mnt} " ]]; then
217
- mkdir -p " ${home_mnt} "
218
- fi
219
-
220
- # Ensure directories that will be mounted are owned by the jenkins user
221
- if [[ " $( id -u) " != 0 ]]; then
222
- echo " Not running as root:"
223
- echo " Checking if j_gid and j_uid are the owners of mounted directories"
224
- # shellcheck disable=SC2012 # use ls to get permissions.
225
- test_1=" $( ls -nd " ${home_mnt} " | awk ' {print $3 " " $4}' ) "
226
- if [[ " ${test_1} " != " ${j_uid} ${j_gid} " ]]; then
227
- echo " Owner of ${home_mnt} is not the jenkins user"
228
- echo " ${test_1} != ${j_uid} ${j_gid} "
229
- will_fail=1
211
+ # Ensure directories that will be mounted exist
212
+ if [[ -n " ${host_import_mnt} " && ! -d " ${host_import_mnt} " ]]; then
213
+ mkdir -p " ${host_import_mnt} "
230
214
fi
231
- if [[ -n " ${host_import_mnt} " ]]; then
232
- # shellcheck disable=SC2012 # use ls to get permissions.
233
- test_2=" $( ls -nd " ${host_import_mnt} " | awk ' {print $3 " " $4}' ) "
234
- if [[ " ${test_2} " != " ${j_uid} ${j_gid} " ]]; then
235
- echo " Owner of ${host_import_mnt} is not the jenkins user"
236
- echo " ${test_2} != ${j_uid} ${j_gid} "
237
- will_fail=1
238
- fi
215
+
216
+ if [[ ! -d " ${home_mnt} " ]]; then
217
+ mkdir -p " ${home_mnt} "
239
218
fi
240
- if [[ " ${will_fail} " == 1 ]]; then
241
- echo " Failing before attempting to launch container"
242
- echo " Try again as root or use correct uid/gid pairs"
243
- exit 1
219
+
220
+ # Ensure directories that will be mounted are owned by the jenkins user
221
+ if [[ " $( id -u) " != 0 ]]; then
222
+ echo " Not running as root:"
223
+ echo " Checking if j_gid and j_uid are the owners of mounted directories"
224
+ # shellcheck disable=SC2012 # use ls to get permissions.
225
+ test_1=" $( ls -nd " ${home_mnt} " | awk ' {print $3 " " $4}' ) "
226
+ if [[ " ${test_1} " != " ${j_uid} ${j_gid} " ]]; then
227
+ echo " Owner of ${home_mnt} is not the jenkins user"
228
+ echo " ${test_1} != ${j_uid} ${j_gid} "
229
+ will_fail=1
230
+ fi
231
+ if [[ -n " ${host_import_mnt} " ]]; then
232
+ # shellcheck disable=SC2012 # use ls to get permissions.
233
+ test_2=" $( ls -nd " ${host_import_mnt} " | awk ' {print $3 " " $4}' ) "
234
+ if [[ " ${test_2} " != " ${j_uid} ${j_gid} " ]]; then
235
+ echo " Owner of ${host_import_mnt} is not the jenkins user"
236
+ echo " ${test_2} != ${j_uid} ${j_gid} "
237
+ will_fail=1
238
+ fi
239
+ fi
240
+ if [[ " ${will_fail} " == 1 ]]; then
241
+ echo " Failing before attempting to launch container"
242
+ echo " Try again as root or use correct uid/gid pairs"
243
+ exit 1
244
+ fi
245
+ else
246
+ if [[ -n " ${host_import_mnt} " ]]; then
247
+ chown -R " ${j_uid} :${j_gid} " " ${host_import_mnt} "
248
+ fi
249
+ chown -R " ${j_uid} :${j_gid} " " ${home_mnt} "
244
250
fi
245
- else
251
+
252
+ # If we don't have import mount don't add to docker command
246
253
if [[ -n " ${host_import_mnt} " ]]; then
247
- chown -R " ${j_uid } :${j_gid} " " ${host_import_mnt }"
254
+ import_vol_cmd= " -v ${host_import_mnt } :${cont_import_mnt } "
248
255
fi
249
- chown -R " ${j_uid} :${j_gid} " " ${home_mnt} "
250
- fi
251
-
252
- # If we don't have import mount don't add to docker command
253
- if [[ -n " ${host_import_mnt} " ]]; then
254
- import_vol_cmd=" -v ${host_import_mnt} :${cont_import_mnt} "
255
- fi
256
- # Launch the jenkins image with Docker
257
- # shellcheck disable=SC2086 # import_vol_cmd is intentially word-split.
258
- docker run -d \
259
- ${import_vol_cmd} \
260
- -v " ${home_mnt} :${j_home} " \
261
- -p " ${http_port} :8080" \
262
- -p " ${agent_port} :${agent_port} " \
263
- --env JAVA_OPTS=\" " ${java_options} " \" \
264
- --env JENKINS_OPTS=\" " ${jenkins_options} " \" \
265
- " ${img_name} "
256
+ # Launch the jenkins image with Docker
257
+ # shellcheck disable=SC2086 # import_vol_cmd is intentially word-split.
258
+ docker run -d \
259
+ ${import_vol_cmd} \
260
+ -v " ${home_mnt} :${j_home} " \
261
+ -p " ${http_port} :8080" \
262
+ -p " ${agent_port} :${agent_port} " \
263
+ --env JAVA_OPTS=\" " ${java_options} " \" \
264
+ --env JENKINS_OPTS=\" " ${jenkins_options} " \" \
265
+ " ${img_name} "
266
266
267
267
fi
0 commit comments