-
Notifications
You must be signed in to change notification settings - Fork 312
/
Copy pathjenkins-2.yaml
167 lines (144 loc) · 5.46 KB
/
jenkins-2.yaml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package:
name: jenkins-2
version: "2.502"
epoch: 0
description: Open-source CI/CD application.
copyright:
- license: MIT
dependencies:
provides:
- jenkins=${{package.full-version}}
runtime:
# Jenkins requires both bash and busybox.
- bash
- busybox
- coreutils
- glibc-locale-en
# The entrypoint script is pulled from a separate repo, which we'e packaged.
- jenkins-entrypoint
- openjdk-17-default-jvm
- ttf-dejavu
- tzdata
environment:
contents:
packages:
- autoconf
- automake
- bash
- build-base
- busybox
- ca-certificates-bundle
- coreutils
- git
- glibc-locale-en
- libxml2-utils
- maven
- openjdk-17-default-jdk
- openssh-client
- patch
- tini
- ttf-dejavu
- tzdata
pipeline:
- uses: git-checkout
with:
repository: https://github.com/jenkinsci/jenkins
tag: jenkins-${{package.version}}
expected-commit: 923af2d4b600580c940f0454e662c5a947d0a20e
- uses: patch
with:
patches: ignoreArchiveNotReadableTest.patch
- uses: maven/pombump
- runs: mvn spotless:apply
- runs: |
# Use commit timestamp as build date to satisfy Jenkins in-place upgrade functionality (.war file needs to match release date)
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct)
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
export LANG=en_US.UTF-8
export MAVEN_OPTS="-DforkCount=2"
# now do something strange to get around invalid git tag versions..
# clone the remoting package, build the jar, and make it available
# for the subpackages pipeline that will actually package it
remoting_version=$(xmllint --xpath "//*[local-name()='remoting.version']/text()" pom.xml)
echo "Remoting version: ${remoting_version}"
git clone https://github.com/jenkinsci/remoting
cd remoting
git checkout "${remoting_version}"
mvn -B -V -e --ntp -Dchangelist="${remoting_version}" -Pquick-build clean package
cd ..
# tests take ~1.5 hours to run and have passed 100% since the initial addition of Jenkins, let's skip them and save time + resources
mvn install -DskipTests=true -Dyarn.lint.skip=true
mkdir -p ${{targets.destdir}}/usr/share/java/jenkins
mv war/target/jenkins.war ${{targets.destdir}}/usr/share/java/jenkins/
subpackages:
# The Jenkins entrypoint script expects directories to exist, and the .war file
# under a different location.
- name: "jenkins-compat"
pipeline:
- runs: |
mkdir -p "${{targets.subpkgdir}}"/var/jenkins_home
mkdir -p "${{targets.subpkgdir}}"/usr/share/jenkins
mkdir -p "${{targets.subpkgdir}}"/usr/share/jenkins/ref
ln -s /usr/share/java/jenkins/jenkins.war "${{targets.subpkgdir}}"/usr/share/jenkins/jenkins.war
# The remoting repo uses difficult to parse tags, so extract the jar here
# in a subpackage. The apk version won't be quite right, but the jar itself
# will match the version jenkins specifies in its pom.xml
- name: "jenkins-remoting"
pipeline:
- runs: |
mkdir -p "${{targets.subpkgdir}}"/usr/share/jenkins
remoting_version=$(xmllint --xpath "//*[local-name()='remoting.version']/text()" pom.xml)
# the jar contains version number sometimes
# example below from the remoting version number
# originating from https://github.com/jenkinsci/remoting/blob/3256.3258.v858f3c9a_f69d/pom.xml#L37
# remoting-3256.3256.3258.v858f3c9a_f69d.jar
# remoting-3256.3258.v858f3c9a_f69d.jar
# Find the correct remoting jar file, excluding *-tests.jar
remoting_jar=$(find remoting/target -name "remoting-*${remoting_version}*.jar" -type f ! -name "*-test*.jar")
if [ -z "$remoting_jar" ]; then
echo "Error: Remoting jar file not found"
exit 1
fi
if [ $(echo "$remoting_jar" | wc -l) -gt 1 ]; then
echo "Error: Multiple matching jar files found:"
echo "$remoting_jar"
exit 1
fi
# Extract just the filename
remoting_jar_name=$(basename "$remoting_jar")
echo "Copying $remoting_jar_name to ${{targets.subpkgdir}}/usr/share/jenkins/"
cp "$remoting_jar" "${{targets.subpkgdir}}"/usr/share/jenkins/
echo "Creating symlinks for agent.jar and slave.jar"
ln -sf "/usr/share/jenkins/${remoting_jar_name}" "${{targets.subpkgdir}}"/usr/share/jenkins/agent.jar
ln -sf "/usr/share/jenkins/${remoting_jar_name}" "${{targets.subpkgdir}}"/usr/share/jenkins/slave.jar
echo "Remoting jar installation completed successfully"
update:
enabled: true
require-sequential: true
github:
identifier: jenkinsci/jenkins
strip-prefix: jenkins-
tag-filter-prefix: jenkins-2
ignore-regex-patterns:
- '.*-rc'
test:
environment:
contents:
packages:
- jenkins-compat
- jenkins-entrypoint
pipeline:
- name: "start daemon on localhost"
uses: test/daemon-check-output
with:
start: jenkins.sh
timeout: 120
expected_output: |
Jenkins is fully up and running
- name: "Check .war timestamp is being set correctly (not zero)"
runs: |
WAR_TIME=$(stat -c %Y /usr/share/java/jenkins/jenkins.war)
if [ "$WAR_TIME" -eq 0 ]; then
echo "WAR file timestamp is zero"
exit 1
fi