d7a9e3139386c376d665b38c36e0a9fadb6116b0
[releng/global-jjb.git] / shell / jjb-verify-job.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 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 "---> jjb-verify-job.sh"
12
13 # Ensure we fail the job if any steps fail.
14 set -eu -o pipefail
15
16 # shellcheck disable=SC1090
17 source ~/lf-env.sh
18
19 lf-git-validate-jira-urls
20 lf-jjb-check-ascii
21
22 lf-activate-venv jenkins-job-builder
23
24 jenkins-jobs -l DEBUG test --recursive -o archives/job-configs --config-xml jjb/
25
26 # Sort job output into sub-directories. On large Jenkins systems that have
27 # many jobs archiving so many files into the same directory makes NGINX return
28 # the directory list slow.
29 pushd archives/job-configs
30 for letter in {a..z}
31 do
32     if [[ $(ls "$letter"* > /dev/null 2>&1) -eq 0 ]]
33     then
34         mkdir "$letter"
35         find . -maxdepth 1 -type f -name "$letter*" -exec mv {} "$letter" \;
36     fi
37 done
38 popd
39
40 if [ -n "$(ls -A archives/job-configs)" ]; then
41     tar cJvf archives/job-configs.tar.xz archives/job-configs
42     rm -rf archives/job-configs
43 fi