-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
105 lines (98 loc) · 5.19 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
# General info: https://docs.gitlab.com/ee/ci/yaml/
# Building maven: https://docs.gitlab.com/ee/user/project/packages/maven_repository.html
variables:
MAVEN_IMAGE17: $CI_REGISTRY_IMAGE/maven:3.9-eclipse-temurin-17jdk
MAVEN_IMAGE21: $CI_REGISTRY_IMAGE/maven:3.9-eclipse-temurin-21jdk
FF_NETWORK_PER_BUILD: 1
# Configure mysql environment variables (https://hub.docker.com/_/mariadb/)
MYSQL_DATABASE: "root"
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
# to use dind-rootless, define 'environment = ["DIND_ROOTLESS=-rootless"]' in runner-config/config.toml additionally to allowed_privileged_services etc., cf. https://docs.gitlab.com/runner/executors/docker.html#use-rootless-docker-in-docker-with-restricted-privileged-mode and https://forum.gitlab.com/t/94101
DOCKER_TLS_CERTDIR: ""
stages:
- prepare
- build
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository
prepare-docker-image:
stage: prepare
needs: []
cache: {}
image: docker:27.0
services:
- name: docker:27.0-dind$DIND_ROOTLESS
command: ["--tls=false"]
script:
- cd .gitlab-ci
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
- docker build --pull -t $MAVEN_IMAGE17 .
- docker push $MAVEN_IMAGE17
- sed -i 's/-17-focal/-21-jammy/' Dockerfile
- docker build --pull -t $MAVEN_IMAGE21 .
- docker push $MAVEN_IMAGE21
- cd tomcat
- cp ../../submissiondir/junit.jar .
- cp ../../SecurityManager/NoExitSecurityManager.jar .
- cp ../../submissiondir/plaggie.properties .
- mkdir lectures
- cp -r ../../src/test/resources/lecture1 lectures/1
- docker build -t $CI_REGISTRY_IMAGE/tomcat:latest .
- docker push $CI_REGISTRY_IMAGE/tomcat:latest
rules:
- if: $UPDATE_CONTAINER
when: always
- changes:
- .gitlab-ci.yml
- .gitlab-ci/Dockerfile
- .gitlab-ci/tomcat/**
when: always
- when: never
compile-jdk17:
image: $MAVEN_IMAGE17
services:
- mariadb:10.11
- name: $CI_REGISTRY_IMAGE/tomcat:latest
alias: tomcat
stage: build
needs:
- job: prepare-docker-image
optional: true
before_script:
- perl -pi -e "s|localhost/[a-zA-Z0-9]+|mariadb/abgabesystem|g" src/main/resources/hibernate.cfg.xml
- perl -pi -e 's|hibernate.show_sql">true|hibernate.show_sql">false|g' src/main/resources/hibernate.cfg.xml
script:
- '[ -z "$SKIP_ONLINE_TESTS" ] && xmlstarlet val -w -e -s http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd src/main/webapp/WEB-INF/web.xml || echo "Skipped"'
- '[ -z "$SKIP_ONLINE_TESTS" ] && xmlstarlet val -w -e -d http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd src/main/resources/hibernate.cfg.xml || echo "Skipped"'
- >
xmlstarlet edit --inplace -N x="http://xmlns.jcp.org/xml/ns/javaee"
--update "/x:web-app/x:context-param[x:param-name[text()='datapath']]/x:param-value" --value "/srv/submissioninterface"
--update "/x:web-app/x:filter[x:filter-name[text()='AuthenticationFilter']]/x:init-param[x:param-name[text()='login']]/x:param-value" --value "de.tuclausthal.submissioninterface.authfilter.authentication.login.impl.Form"
--update "/x:web-app/x:filter[x:filter-name[text()='AuthenticationFilter']]/x:init-param[x:param-name[text()='verify']]/x:param-value" --value "de.tuclausthal.submissioninterface.authfilter.authentication.verify.impl.FakeVerify"
src/main/webapp/WEB-INF/web.xml
- 'mvn $MAVEN_CLI_OPTS verify'
- mysql -u root -h mariadb -e 'create database abgabesystem CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin;'
- mysql -u root -h mariadb abgabesystem < mysql.sql
- mysql -u root -h mariadb abgabesystem < test-data.sql
- curl --no-keepalive -u 'admin:s3cret' -T target/GATE-1.0-SNAPSHOT.war --no-keepalive -s -S -f "http://tomcat:8080/manager/text/deploy?path=/SubmissionInterface&update=true" | tee .deploy-error.tmp ; cat .deploy-error.tmp | grep -q "OK - Deployed application at context path"
- GATE_DB_TESTS=1 GATE_WEB_TESTS="http://tomcat:8080" mvn $MAVEN_CLI_OPTS test
- mvn exec:java -Dexec.mainClass="de.tuclausthal.submissioninterface.util.HibernateSQLExporter"
# keep built artifacts
artifacts:
paths:
- target/*.war
- db-schema.sql
expire_in: 1 week
compile-jdk21:
extends: compile-jdk17
image: $MAVEN_IMAGE21