Skip to content
Permalink
Browse files
FINCN-148 build with travis-ci.com and upload artifacts to Artifactory
  • Loading branch information
Juhan Aasaru authored and Juhan Aasaru committed Apr 25, 2019
1 parent 2556537 commit 0d92ba4c8e7fe3ae525d427776f59211e6b06735
Showing 8 changed files with 134 additions and 4 deletions.
@@ -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: "H9DMI6bUesXtE5friHQMFxJaRzyf7qSdjxJRPilM+E0eGXE91o8HKWTu2mx0ybukxkMjB0PWJt9r3NlgjysMSxpZFNErphtX5wQHWSoPwOiyKkh7kfCMmyst0tJvx86N8Furd0dWEMb4FoWMllKt4hsu2kTjvfL8h/vac2SRgLi8TBh41iltufZGEVBQmxQdF2PkCowpXKprMY5QYe8eEysxEKnu4EvZjPgT5u4c7d/ckM2lyEEDGHhUjJh3X556GV9x71dCvCVPVqzVO4jfcUlBB5baiI7sWzdfbBg3dpbFA0jFJNHCOjvipdkUf2yaESf3rCYpDE7ins+jbweLQyCRYjLczyGYZr+kFD73O5026qyMRH7+N+LvklYaN5lxsC5G3nbc5S8XEPrgmtFo7tnslJmtO95KPWPGYBO+aoLHpBbeaIwkGLqqdC4eqEGVy/queLat4TJt2Ta041p/VJbn4XskMrecl071yT4+dspmFeeTN1wG7Jt6gvtLyNilKrVh9Trw0tpFxD8BIPMu8o3clVl+rwAxrnXOeNN/97h3V9dVi2YaYfn2Ez4LOHZnyqh0eGxYJqDhTSfvfwTOZWgv711YDWYY5svkgxfhhsTtEwKuKpEMeOTRnFt3yC6N9xIR0Un9kSysB0zw1iumWP+UiiMCzMUj/wiGoZaS/5w="
@@ -1,4 +1,4 @@
# Apache Fineract CN Cheques Management
# Apache Fineract CN Cheques Management [![Build Status](https://api.travis-ci.com/apache/fineract-cn-cheques.svg?branch=develop)](https://travis-ci.com/apache/fineract-cn-cheques)

This project provides services to issue, validate cheques and execute transactions on them.

@@ -28,6 +28,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'
@@ -51,7 +52,7 @@ publishing {
from components.java
groupId project.group
artifactId project.name
version project.version
version project.findProperty('externalVersion') ?: project.version
}
}
}
@@ -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
@@ -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'

@@ -51,6 +52,7 @@ publishing {
publications {
mavenJava(MavenPublication) {
from components.java
version project.findProperty('externalVersion') ?: project.version
}
}
}
@@ -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'
@@ -73,14 +74,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
}
}
}
@@ -47,6 +47,7 @@ tasks.withType(JavaCompile) {
repositories {
jcenter()
mavenLocal()
maven { url 'https://mifos.jfrog.io/mifos/libs-snapshot/' }
}

dependencyManagement {
@@ -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', 'componentTest', 'service', 'bootService')
}
}
}
artifactoryPublish.dependsOn('clean','publishToMavenLocal')

license {
header rootProject.file('../HEADER')
strictCheck true
@@ -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 0d92ba4

Please sign in to comment.