gitlab-ci.yml 2.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
#
# The jobs of one stage are going to be run simultaneously.
#
# The verification stage jobs:
#  - verification
#
# The deployment stage jobs:
#  - snapshot
#  - release
#
11 12 13 14
# The trigger stage jobs:
#  - okapi-snapshot-trigger
#
# Normally, on pushing to the code repository the "verification" job is run.
15 16 17 18
#
# If a branch is a "snapshot branch", then the "snapshot" job is run.
# If a branch is a "tag", then the "release" job is run.
#
19 20 21 22 23
# If a branch is a "snapshot branch", then the "okapi-snapshot-trigger"
# job is run.
#
# If any of the jobs fails, no other consequential job is run.
#
24

25
stages:
26 27
  - verification
  - deployment
28
  - trigger
29

30
variables:
31
  CI_GITLAB_PATH: "ci/gitlab"
32
  CI_SCRIPTS_PATH: "${CI_GITLAB_PATH}/scripts"
33
  MAVEN_CLI_OPTS: "--settings ${CI_GITLAB_PATH}/.m2/settings.xml --batch-mode --errors --show-version"
34
  OPENSSL_CLI_OPTS: "enc -aes-256-cbc -K ${OPENSSL_ENC_KEY} -iv ${OPENSSL_ENC_IV}"
35 36
  GPG_CONF: ".gnupg/gpg.conf"
  GPG_AGENT_CONF: ".gnupg/gpg-agent.conf"
Denis Konovalyenko's avatar
Denis Konovalyenko committed
37 38 39
  OKAPI_PROJECT_ID: "9036176"
  OKAPI_SNAPSHOTS_BRANCH: "dev"
  SNAPSHOTS_BRANCH: "dev"
40
#  CI_DEBUG_TRACE: "true" # WARNING: all secret variables will be exposed to a job output!
41

42 43
image: "maven:3.5.3-jdk-8"

44
before_script:
45
  - ${CI_SCRIPTS_PATH}/before-job
46
after_script:
47
  - ${CI_SCRIPTS_PATH}/after-job
48

49 50
verification:
  stage: verification
51 52 53 54
  cache:
    paths:
      - ${HOME}/.m2/repository/
      - ${HOME}/target/
55
  script:
56
    - mvn verify ${MAVEN_CLI_OPTS}
57
    - touch ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
58

59 60
.deployment: &deployment
  stage: deployment
61 62 63 64
  cache:
    paths:
      - ${HOME}/.m2/repository/
      - ${HOME}/target/
65
    policy: pull
66
  script:
67
    - ${CI_SCRIPTS_PATH}/gpg-import
Denis Konovalyenko's avatar
Denis Konovalyenko committed
68
    - mvn deploy ${MAVEN_CLI_OPTS} -DskipITs -Dmaven.test.skip=true --activate-profiles sign_and_deploy,release #--quiet
69
    - touch ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
70 71 72

snapshot:
  <<: *deployment
73 74 75
  only:
    variables:
      - $SNAPSHOTS_BRANCH == $CI_COMMIT_REF_NAME
76 77 78 79
  except:
    - tags
    - master

80
release:
81
  <<: *deployment
82 83 84 85
  only:
    - tags
  except:
    - branches
86 87

okapi-snapshot-trigger:
88
  stage: trigger
89 90 91 92 93
  script:
    - curl -X POST -F token=${OKAPI_TRIGGER_TOKEN} -F ref=${OKAPI_SNAPSHOTS_BRANCH} https://gitlab.com/api/v4/projects/${OKAPI_PROJECT_ID}/trigger/pipeline
    - touch ${CI_GITLAB_PATH}/${CI_JOB_NAME}-passed
  only:
    variables:
94
      - $SNAPSHOTS_BRANCH == $CI_COMMIT_REF_NAME
95 96 97
  except:
    - tags
    - master