Skip to content

Commit 3a1a996

Browse files
committed
Added harness ci:
1 parent de36fbc commit 3a1a996

3 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
pipeline:
2+
name: java-client-ci
3+
identifier: java_client_ci
4+
projectIdentifier: Harness_Split
5+
orgIdentifier: PROD
6+
tags: {}
7+
properties:
8+
ci:
9+
codebase:
10+
connectorRef: fmegithubrunnersci
11+
repoName: java-client
12+
build: <+input>
13+
depth: 0
14+
stages:
15+
- stage:
16+
name: test
17+
identifier: test
18+
type: CI
19+
spec:
20+
cloneCodebase: true
21+
caching:
22+
enabled: true
23+
override: true
24+
platform:
25+
os: Linux
26+
arch: Amd64
27+
runtime:
28+
type: Cloud
29+
spec: {}
30+
execution:
31+
steps:
32+
# JDK 8: build + test + checkstyle (PR only)
33+
- step:
34+
type: Run
35+
name: test jdk8
36+
identifier: test_jdk8
37+
spec:
38+
connectorRef: dockerhub
39+
image: maven:3.9-eclipse-temurin-8
40+
shell: Bash
41+
envVariables:
42+
MAVEN_OPTS: "-XX:InitialHeapSize=2G -XX:MaxHeapSize=2G -XX:+PrintCommandLineFlags -XX:ThreadStackSize=65536 -XX:-TieredCompilation -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
43+
command: |-
44+
apt-get update -qq && apt-get install -y --no-install-recommends redis-server
45+
redis-server --daemonize yes
46+
for i in $(seq 1 30); do
47+
redis-cli ping 2>/dev/null | grep -q PONG && { echo "Redis is up"; break; }
48+
echo "Waiting for Redis... ($i/30)"; sleep 1
49+
done
50+
cp .ci.settings.xml ${HOME}/.m2/settings.xml
51+
mvn --batch-mode clean install
52+
when:
53+
stageStatus: Success
54+
condition: <+codebase.build.type> == "PR"
55+
# JDK 8: checkstyle (PR only, runs after build succeeds)
56+
- step:
57+
type: Run
58+
name: checkstyle jdk8
59+
identifier: checkstyle_jdk8
60+
spec:
61+
connectorRef: dockerhub
62+
image: maven:3.9-eclipse-temurin-8
63+
shell: Bash
64+
envVariables:
65+
MAVEN_OPTS: "-XX:InitialHeapSize=2G -XX:MaxHeapSize=2G -XX:+PrintCommandLineFlags -XX:ThreadStackSize=65536 -XX:-TieredCompilation -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
66+
command: mvn --batch-mode checkstyle:check
67+
when:
68+
stageStatus: Success
69+
condition: <+codebase.build.type> == "PR"
70+
# JDK 11: Sonar (PR and push to master/development)
71+
- step:
72+
type: Run
73+
name: sonar analysis
74+
identifier: sonar_analysis
75+
spec:
76+
connectorRef: dockerhub
77+
image: maven:3.9-eclipse-temurin-11
78+
shell: Bash
79+
envVariables:
80+
MAVEN_OPTS: "-XX:InitialHeapSize=2G -XX:MaxHeapSize=2G -XX:+PrintCommandLineFlags -XX:ThreadStackSize=65536 -XX:-TieredCompilation -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
81+
SONAR_HOST_URL: https://sonar.harness.io
82+
SONAR_TOKEN: <+secrets.getValue("sonarqube-token")>
83+
PR_NUMBER: <+trigger.prNumber>
84+
PR_BRANCH: <+trigger.sourceBranch>
85+
PR_BASE_BRANCH: <+trigger.targetBranch>
86+
BRANCH_NAME: <+trigger.branch>
87+
command: |-
88+
apt-get update -qq && apt-get install -y --no-install-recommends redis-server
89+
redis-server --daemonize yes
90+
for i in $(seq 1 30); do
91+
redis-cli ping 2>/dev/null | grep -q PONG && { echo "Redis is up"; break; }
92+
echo "Waiting for Redis... ($i/30)"; sleep 1
93+
done
94+
cp .ci.settings.xml ${HOME}/.m2/settings.xml
95+
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
96+
mvn --batch-mode clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
97+
-Dsonar.host.url="$SONAR_HOST_URL" \
98+
-Dsonar.token="$SONAR_TOKEN" \
99+
-Dsonar.pullrequest.key="$PR_NUMBER" \
100+
-Dsonar.pullrequest.branch="$PR_BRANCH" \
101+
-Dsonar.pullrequest.base="$PR_BASE_BRANCH"
102+
else
103+
mvn --batch-mode clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
104+
-Dsonar.host.url="$SONAR_HOST_URL" \
105+
-Dsonar.token="$SONAR_TOKEN" \
106+
-Dsonar.branch.name="$BRANCH_NAME"
107+
fi
108+
when:
109+
stageStatus: Success
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
inputSet:
2+
name: pr
3+
identifier: pr
4+
orgIdentifier: PROD
5+
projectIdentifier: Harness_Split
6+
pipeline:
7+
identifier: java_client_ci
8+
properties:
9+
ci:
10+
codebase:
11+
build:
12+
type: PR
13+
spec:
14+
number: <+trigger.prNumber>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
inputSet:
2+
name: push
3+
identifier: push
4+
orgIdentifier: PROD
5+
projectIdentifier: Harness_Split
6+
pipeline:
7+
identifier: java_client_ci
8+
properties:
9+
ci:
10+
codebase:
11+
build:
12+
type: branch
13+
spec:
14+
branch: <+trigger.branch>

0 commit comments

Comments
 (0)