Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.59 KiB
Newer Older
  • Learn to ignore specific revisions
  • Stefan E. Funk's avatar
    Stefan E. Funk committed
    ###
    # PREPARATIONS
    ###
    
    # Some variables
    # TODO: Apply also as a template!
    
    variables:
      # 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: "-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"
      # 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.
      #MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
      MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
      # Nexus Deployment settings, please use env vars in Settings -> CI/CD -> Variables.
      MAVEN_SETTINGS_PATH: ".m2/settings.xml"
      MAVEN_DEPLOY_OPTS: "--settings=$MAVEN_SETTINGS_PATH"
      # File for storing the POM project.version
      VARIABLES_FILE: ./variables.txt
    
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    # Include Java settings from Gitlab templates repo.
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    include:
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
      - project: 'dariah-de/gitlab-templates'
        ref: 'main'
        file: '/templates/.java.gitlab-ci.yml'
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    # Stages...
    
    stages:
      - build_version
      - deploy_java
      - deploy_deb
    
    # Cache downloaded dependencies and plugins between builds.
    # To keep cache across branches add 'key: "$CI_JOB_NAME"'
    cache:
      key: $CI_JOB_NAME
      paths:
        - .m2/repository
    
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    ###
    # JOBS
    ###
    
    
    # Get the project version from main POM file and store it to artifact.
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    Get POM version:
    
      only:
        - develop
    
        - main
    
      stage: build_version
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
      extends:
        - .get-pom-version
    
    
    # Build and deploy all the JARs to GWDG Nexus, and build all the DEBs and store DEBs to artifacts.
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    Build and Deploy JARs:
    
      image: maven:3.8.3-jdk-8
      only:
        - develop
    
        - main
    
      stage: deploy_java
      script:
        - 'mvn $MAVEN_OPTS $MAVEN_CLI_OPTS $MAVEN_DEPLOY_OPTS -U clean deploy -Pdhrep.deb'
      artifacts:
        name: WEBAPP_DEB_PACKAGES
        paths:
    
          - ./oaipmh-webapp/target/*.deb
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    # Deploy DEB files to APTLY repository.
    Deploy develop DEBs:
      stage: deploy_deb
    
      only:
        - develop
      variables:
        PNAME: 'oaipmh-webapp'
        PPATH: '${PNAME}/target'
    
        PKEY: 'SNAPSHOT'
    
        APTLY_TARGET: 'indy-snapshots'
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
      extends:
        - .deploy-deb
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
    Deploy productive DEBs:
      stage: deploy_deb
    
      only:
    
        - main
    
      variables:
        PNAME: 'oaipmh-webapp'
        PPATH: '${PNAME}/target'
    
        PKEY: '${PVERSION}'
    
        APTLY_TARGET: 'indy-releases'
    
    Stefan E. Funk's avatar
    Stefan E. Funk committed
      extends:
        - .deploy-deb