-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
155 lines (122 loc) · 5.08 KB
/
.gitlab-ci.yml
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
image: gitlab.rd.advaoptical.com:4567/at/anden/netemu/ci:java21
# variables:
# GIT_CLEAN_FLAGS: none # ==> Intermediate files (build, test data, etc.) are kept across all jobs ==> No caching necessary
before_script:
- echo "Activating Java ecosystem ..."
- source /root/.sdkman/bin/sdkman-init.sh
- export HOME="$(pwd)" && echo $HOME
- export GRADLE_USER_HOME="$HOME/.gradle" && echo $GRADLE_USER_HOME
- java -version
- gradle -version
- groovy -version
- mvn -version
# Git commands adapted from https://forum.gitlab.com/t/test-if-branch-is-behind-for-merge-request/73789
# and https://stackoverflow.com/a/65084420 ...
- >
if [ -n "$CI_COMMIT_BRANCH" ] ; then
echo "Switching from detached HEAD to actual branch, so Gradle plugin com.palantir.git-version can determine its name ..."
; git switch $CI_COMMIT_BRANCH
; git reset --hard '@{upstream}'
; fi
- gradle printVersion --quiet --warning-mode fail --stacktrace
# - echo "Configure '$(realpath .m2)/repository' as default Maven local repository ..."
# - mkdir -p /root/.m2 && groovy .m2/settings.groovy > /root/.m2/settings.xml && cat /root/.m2/settings.xml
# - ls -x .m2/repository/
# Build/install ODL modules:
# stage: .pre
# tags:
# - docker
# - gdn-s-ae1
# # - muc-vs-ae1
#
# script:
# - echo "Removing all untracked content from repository ..."
# - git clean --force -dx
#
# - echo "Checking out forked Jep & OpenDaylight submodules ..."
# - git submodule update --init --recursive
#
# - echo "Building and installing forked OpenDaylight submodules to Maven local repository ..."
# - gradle mvnInstallOpenDaylightModules --info --warning-mode fail --stacktrace
Validate ODL dependencies:
stage: .pre
tags:
- docker
- gdn-s-ae1
# - muc-vs-ae1
script:
# - gradle dependencies --configuration compileClasspath --quiet --stacktrace
- >
if [ "$(groovy opendaylight-dependencies.groovy)" == "$(< opendaylight-dependencies.txt)" ] ; then
echo "opendaylight-dependencies.txt is up-to-date."
; else
echo "opendaylight-dependencies.txt is outdated! Update it by running:"
; echo
; echo "groovy opendaylight-dependencies.groovy > opendaylight-dependencies.txt"
; exit 1
; fi
Assemble NETEMU:
stage: build
tags:
- docker
- gdn-s-ae1
# - muc-vs-ae1
script:
- echo "Building and packaging NETEMU ..."
- gradle assemble --build-cache --info --warning-mode fail --stacktrace
# - echo "Removing bundled OpenDaylight modules from Maven local repository ..."
# - rm --force --recursive .m2/repository/org/opendaylight
Test NETEMU w/o YANG models:
stage: test
tags:
- docker
- gdn-s-ae1
# - muc-vs-ae1
script:
- echo "Testing NETEMU's Gradle plugin & Java APIs w/Spock unit tests ..."
- gradle test --build-cache --info --warning-mode all --stacktrace
Install & test NETEMU w/YANG models via TestEMU:
stage: test
tags:
- docker
- gdn-s-ae1
# - muc-vs-ae1
script:
- echo "Bundling NETEMU w/custom ODL modules ..."
- gradle jar --build-cache --info --warning-mode fail --stacktrace
- echo "Configuring '$(realpath .m2)/repository' as new Maven local repository, to check if bundling of ODL modules works ..."
- mkdir -p /root/.m2 && groovy .m2/settings.groovy > /root/.m2/settings.xml && cat /root/.m2/settings.xml
- ls -x .m2/repository/
- echo "Installing NETEMU bundled w/custom ODL modules to new, empty Maven local repository ..."
- gradle publishToMavenLocal --build-cache --exclude-task jar --info --warning-mode fail --stacktrace
- test ! -d /root/.m2/repository/com/adva/netemu
- ls -x .m2/repository/com/adva/netemu
- test -d .m2/repository/com/adva/netemu/"$(gradle printVersion --quiet --warning-mode fail --stacktrace)"
- echo "Showing auto-generated 'netEmuVersion' property for TESTEMU ..."
- cat testemu/gradle.properties
# - >
# export NETEMU_VERSION="$(gradle properties --quiet --stacktrace
# | grep --only-matching --perl-regexp '^version:\s*\K(\S+)')"
- echo "Testing NETEMU's Java APIs w/Spock unit tests in TESTEMU, based on YANG ietf-interfaces model ..."
- cd testemu && gradle test --build-cache --info --warning-mode all --stacktrace
Publish NETEMU to Artifactory:
stage: deploy
tags:
- docker
- gdn-s-ae1
# - muc-vs-ae1
script:
- >
if gradle properties --quiet --warning-mode fail --stacktrace | grep --perl-regexp '^(release|snapshot):' ; then
echo "Publishing NETEMU bundled w/custom ODL modules ..."
;
gradle publish --build-cache --build-cache --info --warning-mode fail --stacktrace
--project-prop artifactoryReleaseUrl="$ARTIFACTORY_RELEASE_URL"
--project-prop artifactorySnapshotUrl="$ARTIFACTORY_SNAPSHOT_URL"
--project-prop artifactoryUser="$ARTIFACTORY_USER"
--project-prop artifactoryToken="$ARTIFACTORY_TOKEN"
;
echo "Application successfully deployed."
; else
echo "Not publishing NETEMU, since it is neither marked as release nor snapshot!"
; fi