.gitlab-ci.yml 3.79 KB
Newer Older
1
2
stages:
- verify
3
- visualize
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
4
- deploy
5

6
7
default:
  # Default image
8
  image: registry.orekit.org/orekit/ci-utils/maven:3.3.9-jdk-8
9
10
11
12
13
  # Cache downloaded dependencies and plugins between builds.
  # To keep cache across branches add 'key: "$CI_JOB_REF_NAME"'
  cache:
    paths:
      - .m2/repository
14
15
16
17
18
19
20
21

variables:
  # This will supress 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=.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.
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
22
  MAVEN_CLI_OPTS: "-s .CI/maven-settings.xml --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
23
24
  SONAR_PROJECT_KEY: "${CI_PROJECT_NAMESPACE}:${CI_PROJECT_NAME}"
  SONAR_PROJECT_NAME: "${CI_PROJECT_TITLE} (${CI_PROJECT_NAMESPACE}:${CI_PROJECT_NAME})"
25
26
27
28

verify:
  stage: verify
  script:
29
    - mvn $MAVEN_CLI_OPTS verify site
30
    - test -n "$SONAR_TOKEN" && mvn $MAVEN_CLI_OPTS sonar:sonar
31
32
33
34
          -Dsonar.login=${SONAR_TOKEN}
          -Dsonar.branch.name=${CI_COMMIT_REF_NAME}
          -Dsonar.projectKey="$SONAR_PROJECT_KEY"
          -Dsonar.projectName="$SONAR_PROJECT_NAME"
35
36
37
  artifacts:
    paths:
      - target/*.jar
38
      - target/site
39
40
41
42
    reports:
      junit:
        - target/surefire-reports/*.xml

43
44
45
46
47
48
49
50
51
verify:warning:
  stage: verify
  script:
    - echo "Please, configure SonarQube!"
    - exit 1
  allow_failure: true
  rules:
    - if: $SONAR_TOKEN == null

52
53
54
55
56
57
58
# Convert and import in GitLab coverage data.
# The information is then available directly in merge-request view.
# Cf. https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html
coverage-import:
  stage: visualize
  image: haynes/jacoco2cobertura:1.0.4
  script:
59
60
    # Display total coverage
    - "grep -o '<tfoot.*tfoot>' target/site/jacoco/index.html | sed 's:<[^>]*>: :g'"
61
62
63
64
65
66
67
68
69
70
71
    # convert report from jacoco to cobertura
    - 'python /opt/cover2cover.py target/site/jacoco/jacoco.xml src/main/java > target/site/cobertura.xml'
    # read the <source></source> tag and prepend the path to every filename attribute
    - 'python /opt/source2filename.py target/site/cobertura.xml'
  needs:
    - verify
  dependencies:
    - verify
  artifacts:
    reports:
      cobertura: target/site/cobertura.xml
72
  coverage: '/Total.*?([0-9]{1,3})%/'
73

Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
74
75
76
# On main branches (develop, release-*, master)
# the produced artifacts are deployed on the Nexus of the project
# (https://packages.orekit.org/)
77
deploy:artifacts:
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
78
  stage: deploy
79
  script:
80
    - mvn $MAVEN_CLI_OPTS javadoc:jar source:jar deploy -DskipTests=true -Pci-deploy
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
81
82
  artifacts:
    paths:
Guilhem Bonnefille's avatar
Guilhem Bonnefille committed
83
      - target/*.jar
84
  only:
85
86
87
    - develop@orekit/orekit
    - /^release-[.0-9]+$/@orekit/orekit
    - master@orekit/orekit
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105


deploy:site:
  stage: deploy
  before_script:
  ##
  ## Create the SSH directory and give it the right permissions
  ##
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh

  ##
  ## We're using tr to fix line endings which makes ed25519 keys work
  ## without extra base64 encoding.
  ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
  ##
  - echo "$SSH_SECRET_KEY" > ~/.ssh/id_website
  - chmod 700 ~/.ssh/id_website
106

107
108
109
110
111
112
113
  ##
  ## Add known hosts
  ##
  - cp $SSH_KNOWN_HOSTS ~/.ssh/known_hosts
  script:
  - mvn $MAVEN_CLI_OPTS site:deploy
  only:
114
115
116
  - master@orekit/orekit
  - /^release-[.0-9]+$/@orekit/orekit
  - develop@orekit/orekit