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

Commit

Permalink
Merge pull request #8 from aasaru/artifactory
Browse files Browse the repository at this point in the history
FINCN-148 build with travis-ci.com and upload artifacts to Artifactory
  • Loading branch information
awasum committed Apr 30, 2019
2 parents d528dcc + 0194d1a commit e53cebb
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .travis.yml
@@ -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: "pBilHkQXEbjH9CrtGQ4lwDEWEfk89kDFvGTKTWya4y0riQ/czOCbt+4pQ3NNHqVNMvsPQgtuh0ABIaVV1Ksc6FM8haRD74ehCyGMp+7NTKRmm2Yp41QezvWJ4IW/T0oIquimUXAbmL/0kWDv3NhrgJQVEBOdBAxqwxeY3iwRlTVqHmUgszGlRSbfDhxqe5ydSqAhhcYh2qFdfaXoTMrRqRZn5F3UWoxz0K0Hc2u05xkMgejJuZt4fJzHpLNL92/hBPSa5TiZwJSxWBJIte+mzFG/UxqmDc70/mQUHw5U76K/xJoYrLP7N40+tpcWUYwCPX/P8uus4ZvYSDoNQ6Q7/VDLyQChHjxr2IXKJ1DLWjRRnLFmXooeIPXyEJoZWWxKNcpNBNQ69h2RezL7q4UhP9Xr0LVlBuTti8W7NCpXSqeYuuuhJERy2kPtRRhlatsTagmR9v5c0YximTbouamdHybr8aGJHVvEJyWQP5z/vvJhyBfFRbdy9vGq3PchDyfz/lBeOb21LM9l+f73CYHEjOpGh2Mx9JnGqmV/bIO/En7OB+C9muYn+Po0yYfI8DooBFjLUbVlCMcUq29/enOwQm6h42bDS+pXe2llcmsllxQm3UXJI59pNssa33sElGEBORtHkKIKgRLowAcb1Cr7Z1ShQNmta9mKvU4aZX/nFBg="
4 changes: 1 addition & 3 deletions README.md
@@ -1,6 +1,4 @@
# Apache Fineract CN Api

[![Join the chat at https://gitter.im/mifos-initiative/mifos.io](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mifos-initiative/mifos.io?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Apache Fineract CN Api [![Build Status](https://api.travis-ci.com/apache/fineract-cn-api.svg?branch=develop)](https://travis-ci.com/apache/fineract-cn-api)

This project is an umbrella for all Apache Fineract CN Core components.

Expand Down
24 changes: 21 additions & 3 deletions build.gradle
Expand Up @@ -27,6 +27,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"
}

group 'org.apache.fineract.cn'
Expand Down Expand Up @@ -55,6 +56,7 @@ tasks.withType(JavaCompile) {
repositories {
jcenter()
mavenLocal()
maven { url 'https://mifos.jfrog.io/mifos/libs-snapshot/' }
}

dependencyManagement {
Expand Down Expand Up @@ -82,18 +84,34 @@ jar {
from sourceSets.main.allSource
}


publishing {
publications {
apiPublication(MavenPublication) {
from components.java
groupId project.group
artifactId project.name
version project.version
version findProperty('externalVersion') ?: project.version
}
}
}

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

defaults {
publications ('apiPublication')
}
}
}
artifactoryPublish.dependsOn('clean','publishToMavenLocal')


license {
header rootProject.file('HEADER')
strictCheck true
Expand All @@ -114,4 +132,4 @@ rat {
"gradlew.bat",
"README.md"
]
}
}
71 changes: 71 additions & 0 deletions travis.sh
@@ -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 e53cebb

Please sign in to comment.