aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-09 09:57:29 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-09 09:57:29 +0100
commit51ae28ef61c61992b2a6da4bda4f7d5e35b01ec5 (patch)
treef5744aefba521772d691c3ca6fc3890cddb9de21
parent62e394aa59bbe7a891c6081eb5bf8cb5c11ef7fa (diff)
downloadmoa-id-spss-51ae28ef61c61992b2a6da4bda4f7d5e35b01ec5.tar.gz
moa-id-spss-51ae28ef61c61992b2a6da4bda4f7d5e35b01ec5.tar.bz2
moa-id-spss-51ae28ef61c61992b2a6da4bda4f7d5e35b01ec5.zip
add gitlab CI/CD configuration
-rw-r--r--.cisettings.xml37
-rw-r--r--.gitlab-ci.yml79
2 files changed, 116 insertions, 0 deletions
diff --git a/.cisettings.xml b/.cisettings.xml
new file mode 100644
index 000000000..8556c6a85
--- /dev/null
+++ b/.cisettings.xml
@@ -0,0 +1,37 @@
+<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
+ <servers>
+ <server>
+ <id>gitlab</id>
+ <configuration>
+ <httpHeaders>
+ <property>
+ <name>Job-Token</name>
+ <value>${env.CI_JOB_TOKEN}</value>
+ </property>
+ </httpHeaders>
+ </configuration>
+ </server>
+ <server>
+ <id>gitlab-localbuild</id>
+ <configuration>
+ <httpHeaders>
+ <property>
+ <name>Private-Token</name>
+ <value>${env.PRIVATE_TOKEN}</value>
+ </property>
+ </httpHeaders>
+ </configuration>
+ </server>
+ <server>
+ <id>egizMaven</id>
+ <username>${env.EGIZ_MAVEN_USER}</username>
+ <password>${env.EGIZ_MAVEN_PASSWORD}</password>
+ <configuration>
+ <knownHostsProvider implementation="org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider">
+ <hostKeyChecking>no</hostKeyChecking>
+ </knownHostsProvider>
+ </configuration>
+ </server>
+ </servers>
+</settings>
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 000000000..a0d68b89a
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,79 @@
+image: maven:latest
+
+variables:
+ LC_ALL: "en_US.UTF-8"
+ LANG: "en_US.UTF-8"
+ LANGUAGE: "en_US"
+ LIB_NAME: "MOA-ID"
+ MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true --settings ${CI_PROJECT_DIR}/.cisettings.xml"
+ MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -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"
+ GIT_SUBMODULE_STRATEGY: recursive
+ GIT_DEPTH: "2"
+ SECURE_LOG_LEVEL: "debug"
+
+include:
+ - template: Dependency-Scanning.gitlab-ci.yml
+ - template: Security/SAST.gitlab-ci.yml
+ - template: Secret-Detection.gitlab-ci.yml
+ - template: Code-Quality.gitlab-ci.yml
+
+stages:
+ - assemble
+ - test
+ - package
+ - release
+
+cache:
+ paths:
+ - ".m2/repository"
+
+assemble:
+ stage: assemble
+ except:
+ - tags
+ script: |
+ mvn $MAVEN_CLI_OPTS compile test
+ artifacts:
+ when: always
+ reports:
+ junit: "**/target/surefire-reports/TEST-*.xml"
+
+publishToGitlab:
+ stage: package
+ except:
+ - tags
+ before_script:
+ - mkdir -p ~/.ssh
+ - ssh-keyscan apps.egiz.gv.at >> ~/.ssh/known_hosts
+ - chmod 644 ~/.ssh/known_hosts
+ script: |
+ export VERSION=$(mvn -B help:evaluate -Dexpression=project.version -B | grep -v "\[INFO\]" | grep -Po "\d+\.\d+\.\d+((-\w*)+)?")
+ echo "Publishing version $VERSION for $LIB_NAME to public EGIZ maven"
+ mvn $MAVEN_CLI_OPTS deploy -s .cisettings.xml -P jenkinsDeploy -DskipTests
+ echo "VERSION=$VERSION" >> variables.env
+ artifacts:
+ when: always
+ reports:
+ dotenv: variables.env
+
+release:
+ stage: release
+ image: registry.gitlab.com/gitlab-org/release-cli:latest
+ needs:
+ - job: publishToGitlab
+ artifacts: true
+ when: manual
+ only:
+ - master
+ before_script:
+ - mkdir -p ~/.ssh
+ - ssh-keyscan apps.egiz.gv.at >> ~/.ssh/known_hosts
+ - chmod 644 ~/.ssh/known_hosts
+ script: |
+ echo "Releasing version $VERSION of $LIB_NAME"
+ echo "Publishing version $VERSION to public EGIZ maven"
+ mvn $MAVEN_CLI_OPTS deploy -s .cisettings.xml -P jenkinsDeploy
+ release:
+ name: "$VERSION"
+ tag_name: "v$VERSION"
+ description: "$(cat README.md)"