forked from alkacon/opencms-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_version_properties.sh
executable file
·117 lines (106 loc) · 3.75 KB
/
create_version_properties.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
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
115
116
117
#!/bin/bash
# The OpenCms Version number.
#
# If this script is used in the build process,
# you need to change the version number only here and no where else.
# It can be accessed in OpenCms by OpenCms.getSystemInfo().getVersionNumber().
#
OPENCMS_VERSION_NUMBER="${OpenCmsNumber:-9.5.x}"
OPENCMS_VERSION_NUMBER="${OpenCmsVersionNumber:-$OPENCMS_VERSION_NUMBER}"
#
# The type of build generated.
#
# Values used in the test cases are:
# "Release" for a release build
# "Beta" for a bet build
# "Nightly" for a nightly build
# "Milestone" for a milestone build
# "Manual" for a manual triggered build
# "Auto" for an automated CI build
#
OPENCMS_BUILD_TYPE="${OpenCmsBuildType:-Manual}"
#
# The build system that was used.
#
OPENCMS_BUILD_SYSTEM="${OpenCmsBuildSystem:-Jenkins}"
# The output path/filename where the properties are written.
#
# The idea of this script is as follows:
# In the RCS there is a 'static' variation of the version properties.
# If this script is used, the 'static' file from the RCS will
# be replaced by a dynamically generated version that contains
# more detailed information about the build.
#
if [ -d "$WORKSPACE/opencms" ]; then
OUTPUT_BASE="$WORKSPACE/opencms"
else
OUTPUT_BASE="$WORKSPACE/opencms-core"
fi
if [ ! -d "$OUTPUT_BASE" ]; then
echo "Error: Workspace '$OUTPUT_BASE' not found!"
exit 1
fi
OUTPUT_FILE="$OUTPUT_BASE/src/org/opencms/main/version.properties"
#
# Variables set by the CI/build system.
#
# These will be provided to OpenCms as list of variables that
# can be accessed by OpenCms.getSystemInfo().getBuildInfo().
#
JENKINS_BUILD_NUMBER="${JENKINS_BUILD_NUMBER:-#$BUILD_NUMBER}"
OPENCMS_BUILD_NUMBER="${JENKINS_BUILD_NUMBER:-Unknown}"
OPENCMS_BUILD_DATE=$(date +"%Y-%m-%d %H:%M")
GIT_COMMIT="${GIT_COMMIT:-Unknown}"
OPENCMS_GIT_ID="${GIT_COMMIT:0:7}"
OPENCMS_GIT_BRANCH="${GIT_BRANCH:-Unknown}"
#
# The OpenCms version ID.
#
# This is a condensed String from the variables set above.
# It can be accessed in OpenCms by OpenCms.getSystemInfo().getVersionId().
#
OPENCMS_VERSION_ID="$OPENCMS_BUILD_TYPE $OPENCMS_BUILD_NUMBER ($OPENCMS_GIT_BRANCH - $OPENCMS_GIT_ID) $OPENCMS_BUILD_DATE"
#
# Echo some info to the console.
#
echo "# "
echo "# OpenCms Version Information:"
echo "# "
echo "# Build Type : $OPENCMS_BUILD_TYPE"
echo "# Build System : $OPENCMS_BUILD_SYSTEM"
echo "# Build Number : $OPENCMS_BUILD_NUMBER"
echo "# Version Number: $OPENCMS_VERSION_NUMBER"
echo "# Version ID : $OPENCMS_VERSION_ID"
echo "# Version File : $OUTPUT_FILE"
echo "# Git commit : $OPENCMS_GIT_ID"
echo "# Git branch : $OPENCMS_GIT_BRANCH"
echo "# "
#
# Generate the output file.
#
echo "# " > "$OUTPUT_FILE"
echo "# OpenCms version information." >> "$OUTPUT_FILE"
echo "# Automatically generated by Jenkins build." >> "$OUTPUT_FILE"
echo "# " >> "$OUTPUT_FILE"
#
echo "version.number=$OPENCMS_VERSION_NUMBER" >> "$OUTPUT_FILE"
echo "version.id=$OPENCMS_VERSION_ID" >> "$OUTPUT_FILE"
if [ $OPENCMS_BUILD_TYPE != "Milestone" ]; then
echo "build.number=$OPENCMS_BUILD_NUMBER" >> "$OUTPUT_FILE"
fi
echo "build.date=$OPENCMS_BUILD_DATE" >> "$OUTPUT_FILE"
echo "build.type=$OPENCMS_BUILD_TYPE" >> "$OUTPUT_FILE"
echo "build.system=$OPENCMS_BUILD_SYSTEM" >> "$OUTPUT_FILE"
echo "build.gitid=$OPENCMS_GIT_ID" >> "$OUTPUT_FILE"
echo "build.gitbranch=$OPENCMS_GIT_BRANCH" >> "$OUTPUT_FILE"
#
# Nice names for the build information (optional).
#
if [ $OPENCMS_BUILD_TYPE != "Milestone" ]; then
echo "nicename.build.number=Build Number" >> "$OUTPUT_FILE"
fi
echo "nicename.build.date=Build Date" >> "$OUTPUT_FILE"
echo "nicename.build.type=Build Type" >> "$OUTPUT_FILE"
echo "nicename.build.system=Build System" >> "$OUTPUT_FILE"
echo "nicename.build.gitid=Git Commit ID" >> "$OUTPUT_FILE"
echo "nicename.build.gitbranch=Git Branch" >> "$OUTPUT_FILE"