-
Notifications
You must be signed in to change notification settings - Fork 2
/
jenkins.sh
executable file
·81 lines (62 loc) · 2.14 KB
/
jenkins.sh
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
#! /bin/bash
# Gateway script for CI functionality.
# TOPDIR is the path to the top of the rpmbuild output tree. We have to set
# it here so that each step uses the same value. Packages are written there
# after being built, then signed, then pushed to the EOL package repository.
# If the Jenkins WORKSPACE environment variable is set, then use it to set
# TOPDIR. Otherwise use the default that build_rpm.sh would use.
if [ -n "$WORKSPACE" ]; then
export TOPDIR=$WORKSPACE/rpm_build
fi
export TOPDIR=${TOPDIR:-$(rpmbuild --eval %_topdir)_$(hostname)}
# In EOL Jenkins, these are global properties set in Manage Jenkins ->
# Configure System. Provide defaults here to test outside of Jenkins.
DEBIAN_REPOSITORY="${DEBIAN_REPOSITORY:-/net/ftp/pub/archive/software/debian}"
YUM_REPOSITORY="${YUM_REPOSITORY:-/net/www/docs/software/rpms}"
export DEBIAN_REPOSITORY YUM_REPOSITORY
export GPGKEY="NCAR EOL Software <[email protected]>"
echo WORKSPACE=$WORKSPACE
echo TOPDIR=$TOPDIR
echo DEBIAN_REPOSITORY=$DEBIAN_REPOSITORY
echo YUM_REPOSITORY=$YUM_REPOSITORY
build_rpms()
{
# Only clean the rpmbuild space if it's Jenkins, since otherwise it can be
# the user's local rpmbuild space with unrelated packages, and we should
# not go around removing them.
if [ -n "$WORKSPACE" ]; then
(set -x; rm -rf "$TOPDIR/RPMS"; rm -rf "$TOPDIR/SRPMS")
fi
# this conveniently creates a list of built rpm files in rpms.txt.
(set -x; scons build_rpm scripts/eol_scons.spec build)
}
sign_rpms()
{
(set -x; exec rpm --addsign --define="%_gpg_name ${GPGKEY}" --define='_gpg_digest_algo sha256' `cat rpms.txt`)
}
push_eol_repo()
{
source $YUM_REPOSITORY/scripts/repo_funcs.sh
move_rpms_to_eol_repo `cat rpms.txt`
update_eol_repo $YUM_REPOSITORY
}
method="${1:-help}"
shift
case "$method" in
build_rpms)
build_rpms "$@"
;;
sign_rpms)
sign_rpms
;;
push_rpms)
push_eol_repo
;;
*)
if [ "$method" != "help" ]; then
echo Unknown command "$1".
fi
echo Available commands: build_rpms, sign_rpms, push_rpms.
exit 1
;;
esac