Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / shell / sigul-sign-dir.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> sigul-sign-dir.sh"
12
13 # Ensure we fail the job if any steps fail.
14 set -e -o pipefail
15
16 # shellcheck disable=SC1090
17 . ~/lf-env.sh
18
19 lf-activate-venv --python python3 lftools
20
21 OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
22 OS_RELEASE=$(facter lsbdistrelease | tr '[:upper:]' '[:lower:]')
23 if [[ "$OS_RELEASE" == "8" && "$OS" == 'centos' ]]; then
24     # Get Dockerfile and the enterpoint to build the docker image.
25     # shellcheck disable=SC2140
26     wget -O "${WORKSPACE}/sigul-sign.sh" "https://raw.githubusercontent.com/"\
27 "lfit/releng-global-jjb/master/shell/sigul-sign.sh"
28     # shellcheck disable=SC2140
29     wget -O "${WORKSPACE}/Dockerfile" "https://raw.githubusercontent.com/"\
30 "lfit/releng-global-jjb/master/docker/Dockerfile"
31
32     # Setup the docker environment for jenkins user
33     docker build -f "${WORKSPACE}/Dockerfile" \
34         --build-arg SIGN_DIR="${SIGN_DIR}" \
35         -t sigul-sign .
36
37     docker volume create --driver local \
38         --opt type=none \
39         --opt device=/w/workspace \
40         --opt o=bind \
41         wrkspc_vol
42
43     docker volume inspect wrkspc_vol
44
45     # shellcheck disable=SC2140
46     docker run -e SIGUL_KEY="${SIGUL_KEY}" \
47         -e SIGUL_PASSWORD="${SIGUL_PASSWORD}" \
48         -e SIGUL_CONFIG="${SIGUL_CONFIG}" \
49         -e SIGN_DIR="${SIGN_DIR}" \
50         -e WORKSPACE="${WORKSPACE}" \
51         --name sigul-sign \
52         --security-opt label:disable \
53         --mount type=bind,source="/w/workspace",target="/w/workspace" \
54         --mount type=bind,source="/home/jenkins",target="/home/jenkins" \
55         -u root:root -w "$(pwd)" sigul-sign
56
57     # change the .asc files owner permissions back to jenkins
58     sudo chown -R jenkins:jenkins "${SIGN_DIR}"
59 else
60     lftools sign sigul -m "${SIGN_MODE}" "${SIGN_DIR}"
61 fi