Skip to content

Commit 8f9258c

Browse files
committed
Add CircleCI support
1 parent 6800b63 commit 8f9258c

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

.circleci/config.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
version: 2.1
3+
4+
executors:
5+
build-executor:
6+
docker:
7+
- image: circleci/openjdk:8-jdk-stretch
8+
9+
release-executor:
10+
docker:
11+
- image: opennms/ghr:0.13.0-b4241
12+
jobs:
13+
build:
14+
executor: build-executor
15+
steps:
16+
- checkout
17+
- restore_cache:
18+
key: pris-xls-plugin-{{ checksum "pom.xml" }}
19+
- run:
20+
name: Fetch version number from pom.xml
21+
command: |
22+
.circleci/scripts/pom2version.py pom.xml > version.txt
23+
- run:
24+
name: Validate Maven project
25+
command: |
26+
mvn validate
27+
- run:
28+
name: Compile application
29+
command: |
30+
mvn install
31+
- save_cache:
32+
key: pris-xls-plugin-{{ checksum "pom.xml" }}
33+
paths:
34+
- ~/.m2
35+
- persist_to_workspace:
36+
root: ~/
37+
paths:
38+
- project
39+
40+
release-github:
41+
executor: release-executor
42+
steps:
43+
- attach_workspace:
44+
at: ~/
45+
- run:
46+
name: Collect artifacts and publish archives to GitHub
47+
command: |
48+
mkdir github-latest
49+
cp kar/target/opennms-pris-plugin.kar github-latest/opennms-pris-plugin-$(cat version.txt).kar
50+
if [[ "develop" == "${CIRCLE_BRANCH}" ]]; then
51+
GHR_OPTS="-prerelease -replace"
52+
fi
53+
ghr ${GHR_OPTS} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} $(cat version.txt) github-latest
54+
workflows:
55+
commit:
56+
jobs:
57+
- build
58+
- release-github:
59+
requires:
60+
- build
61+
filters:
62+
branches:
63+
only:
64+
- master
65+
- develop

.circleci/scripts/pom2version.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python2
2+
import xml.etree.ElementTree as ET
3+
import argparse
4+
5+
if __name__ == "__main__":
6+
parser = argparse.ArgumentParser(description="Get version number from a given POM file.")
7+
parser.add_argument("path", help="Relative or absolute path to pom.xml file to read the version from.")
8+
args = parser.parse_args()
9+
version = ET.parse(open(args.path)).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text
10+
11+
print(version)

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0-SNAPSHOT

0 commit comments

Comments
 (0)