Skip to content
Snippets Groups Projects
Commit 12ab3cab authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

Add gitlab templates

parent 5426a8f6
No related branches found
No related tags found
No related merge requests found
Pipeline #291075 passed
###
# PREPARATIONS
###
# Some variables
# TODO: Apply also as a template!
variables: variables:
# defaults to java 11 (https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#configuring-specific-analyzers-used-by-dependency-scanning)
DS_JAVA_VERSION: 8
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log. # 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. # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
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" 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"
...@@ -14,30 +18,14 @@ variables: ...@@ -14,30 +18,14 @@ variables:
# File for storing the POM project.version # File for storing the POM project.version
VARIABLES_FILE: ./variables.txt VARIABLES_FILE: ./variables.txt
# Include Java settings from Gitlab templates repo.
include: include:
- template: Dependency-Scanning.gitlab-ci.yml - project: 'dariah-de/gitlab-templates'
ref: 'main'
################### file: '/templates/.java.gitlab-ci.yml'
### TEMPLATES ###
###################
.webapp: &webapp
image: alpine:3.14
stage: deploy_deb
script:
- source $VARIABLES_FILE
- 'apk add --no-cache bash'
- 'apk add --no-cache curl'
- export PLOC="$(ls ./${PPATH}/*.deb)"
- DEB_NAME=$PNAME-$PVERSION.deb
- 'if [[ $PVERSION =~ .*${PKEY}$ ]]; then'
- echo "---AN APTLY DEPLOYMENT IS BEING PERFORMED for $DEB_NAME in $PLOC into ${APTLY_TARGET}---"
- 'curl -u ${APTLY_USER}:${APTLY_PASSWORD} -X POST --header "Content-Type:multipart/form-data" -F file=@${PLOC} ${APTLY_URL}/files/${DEB_NAME}'
- 'curl -u ${APTLY_USER}:${APTLY_PASSWORD} -X POST ${APTLY_URL}/repos/${APTLY_TARGET}/file/${DEB_NAME}'
- 'curl -u ${APTLY_USER}:${APTLY_PASSWORD} -X PUT -H "Content-Type: application/json" --data "{}" ${APTLY_URL}/publish/:./indy'
- fi
# Stages...
stages: stages:
- test
- build_version - build_version
- deploy_java - deploy_java
- deploy_deb - deploy_deb
...@@ -49,25 +37,21 @@ cache: ...@@ -49,25 +37,21 @@ cache:
paths: paths:
- .m2/repository - .m2/repository
###
# JOBS
###
# Get the project version from main POM file and store it to artifact. # Get the project version from main POM file and store it to artifact.
get_version: Get POM version:
image: maven:3.8.3-jdk-8
only: only:
- develop - develop
- main - main
- branches
stage: build_version stage: build_version
script: extends:
- 'PVERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.version -q -DforceStdout)' - .get-pom-version
- echo "export PVERSION=$PVERSION" > $VARIABLES_FILE
- echo "Project version from main pom file is $PVERSION"
artifacts:
name: POM_VERSION
paths:
- $VARIABLES_FILE
# Build and deploy all the JARs to GWDG Nexus, and build all the DEBs and store DEBs to artifacts. # Build and deploy all the JARs to GWDG Nexus, and build all the DEBs and store DEBs to artifacts.
build_and_deploy: Build and Deploy JARs:
image: maven:3.8.3-jdk-8 image: maven:3.8.3-jdk-8
only: only:
- develop - develop
...@@ -80,17 +64,9 @@ build_and_deploy: ...@@ -80,17 +64,9 @@ build_and_deploy:
paths: paths:
- ./oaipmh-webapp/target/*.deb - ./oaipmh-webapp/target/*.deb
# Just build any branch and test. NO JAR, NO DEB deployed hrer! # Deploy DEB files to APTLY repository.
#build_and_deploy: Deploy develop DEBs:
# image: maven:3.8.3-jdk-8 stage: deploy_deb
# only:
# - branches
# stage: deploy_java
# script:
# - 'mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean verify'
# Deploy SNAPSHOT DEB file to APTLY repository.
deploy_oaipmh-webapp_dev:
only: only:
- develop - develop
variables: variables:
...@@ -98,10 +74,11 @@ deploy_oaipmh-webapp_dev: ...@@ -98,10 +74,11 @@ deploy_oaipmh-webapp_dev:
PPATH: '${PNAME}/target' PPATH: '${PNAME}/target'
PKEY: 'SNAPSHOT' PKEY: 'SNAPSHOT'
APTLY_TARGET: 'indy-snapshots' APTLY_TARGET: 'indy-snapshots'
<<: *webapp extends:
- .deploy-deb
# Deploy RELEASE DEB file to APTLY repository. Deploy productive DEBs:
deploy_oaipmh-webapp_prd: stage: deploy_deb
only: only:
- main - main
variables: variables:
...@@ -109,4 +86,5 @@ deploy_oaipmh-webapp_prd: ...@@ -109,4 +86,5 @@ deploy_oaipmh-webapp_prd:
PPATH: '${PNAME}/target' PPATH: '${PNAME}/target'
PKEY: '${PVERSION}' PKEY: '${PVERSION}'
APTLY_TARGET: 'indy-releases' APTLY_TARGET: 'indy-releases'
<<: *webapp extends:
- .deploy-deb
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment