You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Jenkins shared library with a collection of pipeline steps and functionality useful when setting up a Jenkins CI pipeline for Unity projects. In addition to Unity specific functionality, there is also a selection of more generic functions and steps that have proven useful when setting up continuous integration for game dev projects.
|[github.createCheckRun](#github-create-check-run)| Create a check run. |
40
+
|[github.updateCheckRun](#github-update-check-run)| Update a check run. |
41
+
9
42
## Installation
43
+
10
44
Read the [Extending with Shared Libraries > Using Libraries](https://www.jenkins.io/doc/book/pipeline/shared-libraries/#using-libraries) section in Jenkins User Handbook for full instruction how to add a shared library to a Jenkins instance and how to access the functionality from a `Jenkinsfile`.
11
45
12
46
When using the library in a Jenkinsfile, use a version specifier, to avoid surprises if future updates of the library introduces breaking changes.
13
47
14
48
```groovy
15
-
@Library('shared-library@v1.0.3') _
49
+
@Library('shared-library@v1.0.4') _
16
50
```
17
51
18
52
### Pipeline Utility Steps
53
+
19
54
Several functions in this library uses functions from the Jenkins plugin [Pipeline Utility Steps](https://plugins.jenkins.io/pipeline-utility-steps/). Make sure this plugin is installed in the Jenkins instance using this shared library.
20
55
21
56
### GitHub App
22
-
For the GitHub specific steps a GitHub app must be registered to obtain the access token for Jenkins to communicate with the GitHub API. It also requires the Jenkins plugins
57
+
58
+
For the GitHub specific steps a GitHub app must be registered to obtain the access token for Jenkins to communicate with the GitHub API. It also requires the Jenkins plugins
23
59
24
60
## Pipeline Steps and Functions
61
+
25
62
An overview of the pipeline steps and functionality this shared library exposes.
26
63
27
64
### Unity Specific
65
+
28
66
#### Unity Build Number
29
-
This function parses Unity's Project Settings and returns the build number that has been set
67
+
68
+
This function parses Unity's Project Settings and returns the build number that has been set
30
69
for the Standalone build in Unity's `Project Settings > Player > Build`.
31
70
32
71
```groovy
@@ -36,6 +75,7 @@ steps {
36
75
```
37
76
38
77
#### Unity Code Coverage Report
78
+
39
79
Runs Unity's Code Coverage reporter. This assumes the Unity project has the Code Coverage package installed.
40
80
41
81
The reporter takes two parameters, `unityCodeCoverageReport(assemblyFilters, pathFilters)`.
@@ -48,23 +88,26 @@ post {
48
88
}
49
89
}
50
90
```
91
+
51
92
#### Unity Code Coverage Report Summary
93
+
52
94
Parses `Summary.xml` from the Unity generated code coverage report and returns the summary as an object with the summary items as properties. This can then be posted to Discord, Slack, a time series database, or any other destination.
Publishes the Unity Code Coverage Report so it's available from the job page.
69
112
70
113
```groovy
@@ -76,6 +119,7 @@ post {
76
119
```
77
120
78
121
#### Unity Test Runner
122
+
79
123
Uses Unity's Test Runner to execute the test suite.
80
124
81
125
```groovy
@@ -85,6 +129,7 @@ steps {
85
129
```
86
130
87
131
#### Unity Test Runner Report
132
+
88
133
Creates a merged report from Unitys PlayMode and EditMode test files.
89
134
90
135
```groovy
@@ -96,14 +141,15 @@ post {
96
141
```
97
142
98
143
#### tests
144
+
99
145
Parses the results from the Unity test runner and returns the summary as an object. This can then be posted to Discord, Slack, a time series database, or any other destination.
Retrieves the build type for the current running build based on branch name prefixes. This is useful to rely on branch names to determine the build logic.
117
162
118
-
- internal: `/feature/*`
119
-
- testflight: `/testflight/*`
120
-
- release: `/release/*`
121
-
- standard: `*`
163
+
Retrieves the build type for the current running build based on branch name prefixes. This is useful to rely on branch names to determine the build logic.
164
+
165
+
- internal: `/feature/*`
166
+
- testflight: `/testflight/*`
167
+
- release: `/release/*`
168
+
- standard: `*`
122
169
123
170
```groovy
124
171
steps {
125
-
echo "Build type: ${git.getBuildType()}"
172
+
echo "Build type: ${getBuildType()}"
126
173
}
127
174
```
128
175
129
-
130
176
#### Set Job Display Name
177
+
131
178
Sets name for the running job based on git branch name.
179
+
132
180
```groovy
133
181
steps {
134
182
setJobDisplayName()
135
183
}
136
184
```
137
185
138
186
#### Git Branch Name
187
+
139
188
Get the current branch name.
140
189
141
190
```groovy
@@ -145,6 +194,7 @@ steps {
145
194
```
146
195
147
196
#### Git Commit SHA
197
+
148
198
Get the full git commit sha for current commit.
149
199
150
200
```groovy
@@ -154,6 +204,7 @@ steps {
154
204
```
155
205
156
206
#### Git Commit SHA Short
207
+
157
208
Get the short 7 character git commit sha for current commit.
158
209
159
210
```groovy
@@ -162,7 +213,18 @@ steps {
162
213
}
163
214
```
164
215
216
+
#### Git Trailer Value
217
+
218
+
Get the [trailer](https://git-scm.com/docs/git-interpret-trailers) value for the specified token for the current commit.
219
+
220
+
```groovy
221
+
steps {
222
+
echo "Git commit message trailer value : ${git.getTrailerValue('some-token')}"
223
+
}
224
+
```
225
+
165
226
#### GitHub Pull Request Comment
227
+
166
228
Creates or updates the Jenkins bot issue comment for the pull request.
167
229
168
230
This can be used to have a comment in the PR that Jenkins updates with current information about the build.
@@ -173,54 +235,60 @@ steps {
173
235
}
174
236
```
175
237
176
-
177
238
#### GitHub Owner Repo
239
+
178
240
Get the <owner/repo> part from the project's git url.
179
241
180
242
```groovy
181
243
def owner = github.ownerRepo()
182
244
```
183
245
184
246
#### GitHub Pull Request
247
+
185
248
Returns the pull request the current commit belongs to.
Gradle is used to test the pipeline during development.
312
+
313
+
### Running Tests
314
+
315
+
The test suite is executed with:
316
+
317
+
```sh
318
+
./gradlew test
319
+
```
320
+
321
+
Then gradle is executed for the first time in a session a daemon is started. Manage the daemon with these commands.
322
+
323
+
```sh
324
+
## See running daemons
325
+
gradle --status
326
+
327
+
## Stop running daemons
328
+
gradle --stop
329
+
```
330
+
331
+
### macOS
332
+
333
+
Gradle needs Java runtime, and the version of Gradle used in this project uses Java 17. Install Java 17 with Homebrew and then set `JAVA_HOME` in the terminal, for the session, in the terminal.
0 commit comments