Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
FINCN-148 build with travis-ci.com and upload artifacts to Artifactory
Browse files Browse the repository at this point in the history
  • Loading branch information
aasaru committed Apr 25, 2019
1 parent dd30cde commit 88f47d0
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
language: java
sudo: false
jdk:
- openjdk8
install: true
script: "./travis.sh"
env:
global:
- BUILD_SNAPSHOTS_BRANCH=develop
- ARTIFACTORY_URL=https://mifos.jfrog.io/mifos
- ARTIFACTORY_USER=travis-ci
- secure: "kp9z1hkzXNbhuCeWSKnJOarMElio6ojjPDmpEygDRXj6CUrZiQM7ZVfYyqwKuLuXBDGV3bYLDkwtIk6aan9cjz0u1FnPcAhqwV1Y9HQv00Z9LaHtv65RSAu4DEET6eq6bfmL0bbsgqSp0wMMDjNmVvbWDAxsGILMeqlwRPjmH8X5jyYNaGRihsGkx1CkvBNYtZ1SL+O5+vmK+M1oxoLtb5hef8UYZIJM0xO7h3X5xYmJbh9yOVIGkth6+oicMnoWsU0tPv/qewA13C9S8v3FO/vNws7oh2lJ8N/ZJjD5hDCyXiwFZh7YIOZ6WssdISibQsfUqNHxFs2WT9tF8mmXnreFaOLr4qZzqeZcUSrKT32ADuLYYXV1ZjucMymehEpDfAj6WHgiYEBYALwjIzjmSDkDs48UEwpQO+4p7gN2mdS7Z6fB0Be3adWvjTwfv/2vQI5UD3bKgGZsmNgpGElCA2YmZa4l2I8w/zXZgPSmATTGZswvt63NKsVOGHktDhrEt/8t6Af9PGlGpQjGD2WxZh9ODrSmfNusgnv3wY7qHK5jNkjqCXMj5aFRLsTEQrNeLd2IMJG2aZqUm6afYjzNIIx+/anxXqijS16IuNsBUyOyjsSIcPcey6L/rlBv+WgDCZOC6mx0mkAU9Bbh465PFMBc0IciEYhEVNQ3jufz8fE="
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
FROM openjdk:8-jdk-alpine

ARG office_port=2023
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Apache Fineract CN Office Management
# Apache Fineract CN Office Management [![Build Status](https://api.travis-ci.com/apache/fineract-cn-office.svg?branch=develop)](https://travis-ci.com/apache/fineract-cn-office)

This service manages an organization and its employees.

Expand All @@ -23,4 +23,4 @@ The versioning layout is {MAJOR}.{MINOR}.{PATCH}-{INDICATOR}[.{PATCH}]. Only mil
2.0.0-RELEASE

## License
See [LICENSE](LICENSE) file.
See [LICENSE](LICENSE) file.
3 changes: 2 additions & 1 deletion api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ buildscript {
plugins {
id "com.github.hierynomus.license" version "0.13.1"
id("org.nosphere.apache.rat") version "0.3.1"
id "com.jfrog.artifactory" version "4.9.5"
}

apply from: '../shared.gradle'
Expand All @@ -47,7 +48,7 @@ publishing {
from components.java
groupId project.group
artifactId project.name
version project.version
version project.findProperty('externalVersion') ?: project.version
}
}
}
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ task publishToMavenLocal {
dependsOn publishComponentTestToMavenLocal
}

task artifactoryPublish {
group 'all'
dependsOn publishToMavenLocal
dependsOn gradle.includedBuild('api').task(':artifactoryPublish')
dependsOn gradle.includedBuild('service').task(':artifactoryPublish')
dependsOn gradle.includedBuild('component-test').task(':artifactoryPublish')
}

task prepareForTest {
group 'all'
dependsOn publishToMavenLocal
Expand Down
4 changes: 3 additions & 1 deletion component-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ buildscript {
plugins {
id "com.github.hierynomus.license" version "0.13.1"
id("org.nosphere.apache.rat") version "0.3.1"
id "com.jfrog.artifactory" version "4.9.5"
}

apply from: '../shared.gradle'
Expand Down Expand Up @@ -61,8 +62,9 @@ asciidoctor {

publishing {
publications {
mavenJava(MavenPublication) {
componentTest(MavenPublication) {
from components.java
version project.findProperty('externalVersion') ?: project.version
}
}
}
5 changes: 3 additions & 2 deletions service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ buildscript {
plugins {
id "com.github.hierynomus.license" version "0.13.1"
id("org.nosphere.apache.rat") version "0.3.1"
id "com.jfrog.artifactory" version "4.9.5"
}

apply from: '../shared.gradle'
Expand Down Expand Up @@ -68,14 +69,14 @@ publishing {
from components.java
groupId project.group
artifactId project.name
version project.version
version project.findProperty('externalVersion') ?: project.version
}
bootService(MavenPublication) {
// "boot" jar
artifact("$buildDir/libs/$project.name-$version-boot.jar")
groupId project.group
artifactId("$project.name-boot")
version project.version
version project.findProperty('externalVersion') ?: project.version
}
}
}
18 changes: 18 additions & 0 deletions shared.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tasks.withType(JavaCompile) {
repositories {
jcenter()
mavenLocal()
maven { url 'https://mifos.jfrog.io/mifos/libs-snapshot/' }
}

configurations {
Expand Down Expand Up @@ -77,6 +78,22 @@ jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

artifactory {
contextUrl = System.getenv("ARTIFACTORY_URL")
publish {
repository {
repoKey = project.findProperty('artifactoryRepoKey')
username = System.getenv("ARTIFACTORY_USER")
password = System.getenv("ARTIFACTORY_PASSWORD")
}

defaults {
publications ('api', 'service', 'bootService', 'componentTest')
}
}
}
artifactoryPublish.dependsOn('clean','publishToMavenLocal')

license {
header rootProject.file('../HEADER')
strictCheck true
Expand All @@ -91,6 +108,7 @@ license {
rat {
// List of exclude directives, defaults to ['**/.gradle/**']
excludes = [
"**/.dockerignore/**",
"**/.idea/**",
"**/.gradle/**",
"**/gradle/**",
Expand Down
71 changes: 71 additions & 0 deletions travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Documentation: https://cwiki.apache.org/confluence/display/FINERACT/Fineract-CN+Artifactory

#Exit immediately if a command exits with a non-zero status.
set -e
EXIT_STATUS=0

# Builds and Publishes a SNAPSHOT
function build_snapshot() {
echo -e "Building and publishing a snapshot out of branch [$TRAVIS_BRANCH]"
./gradlew -PartifactoryRepoKey=libs-snapshot-local -DbuildInfo.build.number=${TRAVIS_COMMIT::7} artifactoryPublish --stacktrace || EXIT_STATUS=$?
}

# Builds a Pull Request
function build_pullrequest() {
echo -e "Building pull request #$TRAVIS_PULL_REQUEST of branch [$TRAVIS_BRANCH]. Won't publish anything to Artifactory."
./gradlew publishToMavenLocal rat || EXIT_STATUS=$?
}

# For other branches we need to add branch name as prefix
function build_otherbranch() {
echo -e "Building a snapshot out of branch [$TRAVIS_BRANCH] and publishing it with prefix '${TRAVIS_BRANCH}-SNAPSHOT'"
./gradlew -PartifactoryRepoKey=libs-snapshot-local -DbuildInfo.build.number=${TRAVIS_COMMIT::7} -PexternalVersion=${TRAVIS_BRANCH}-SNAPSHOT artifactoryPublish --stacktrace || EXIT_STATUS=$?
}

# Builds and Publishes a Tag
function build_tag() {
echo -e "Building tag [$TRAVIS_TAG] and publishing it as a release"
./gradlew -PartifactoryRepoKey=libs-release-local -PexternalVersion=$TRAVIS_TAG artifactoryPublish --stacktrace || EXIT_STATUS=$?

}

echo -e "TRAVIS_BRANCH=$TRAVIS_BRANCH"
echo -e "TRAVIS_TAG=$TRAVIS_TAG"
echo -e "TRAVIS_COMMIT=${TRAVIS_COMMIT::7}"
echo -e "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"

# Build Logic
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
build_pullrequest
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" != "$BUILD_SNAPSHOTS_BRANCH" ] && [ "$TRAVIS_TAG" == "" ] ; then
build_otherbranch
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "$BUILD_SNAPSHOTS_BRANCH" ] && [ "$TRAVIS_TAG" == "" ] ; then
build_snapshot
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
build_tag
else
echo -e "WARN: Unexpected env variable values => Branch [$TRAVIS_BRANCH], Tag [$TRAVIS_TAG], Pull Request [#$TRAVIS_PULL_REQUEST]"
./gradlew clean build
fi

exit ${EXIT_STATUS}

0 comments on commit 88f47d0

Please sign in to comment.