Skip to content
Permalink
Browse files
Merge pull request #5 from aasaru/artifactory
FINCN-148 build with travis-ci.com and upload artifacts to Artifactory
  • Loading branch information
awasum committed Apr 30, 2019
2 parents 6ec6c01 + f02f997 commit d7ad8706dfe1dcec4cb46ea7bcb9d74ab344a732
Showing 9 changed files with 136 additions and 5 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: "EJtmkFC8+ZrIJbzd3joFlhG/W6aOZ7TR803UL5EMNZG0VktoFezudt72D5Ii221cMhgHu9YQsCdGO8hgIaW1UoR68eXsAAtmtneFef7uwJ5100DYTUVcvLQOR1pKRlNqox6Shu6ocSoqIfDvt07PbkmtKP10p7abLAuWs9d7ITOlgiWUkXIZdeKKkHrhSdcwXVRmOr+h2rL3RdA5w0r0seY+AM4Ng8jHG94YZcukJeaHTVADvLxHx+wk9+8vwIbLdVrCN18dlnCUDs5+jLPN0/cjLGs2CY8gY+XYPXqlDCoRwOU3sV/eCZFLZi+U9d9JLPEdGxcAB2PPxwUbR+bktxt1XigzpFq6/kR3dg5TNMseH4mN4V588TCiacOiEAM+h2J16bBfrTgZ8q3+m1qmsuJ2U13Kh3rTEApQMOt91sDVAhUpn4T4ml9+gTMyL3wX0iz9CumOx54b23FFiN55Rtu4pUTOCA8jRPZtS0rc2+ZDY2lGyYZVLyegMVv+RlifWZQ3vxJSVVrzd6LN7hmW+3l/s6Pix5443p7tqnbcGVpsGkFpcuk+yOjF8ESifTktBYbBKG/Gi9lL7fTuijNHcU5+Wm3ZoUu9DI/RqjaQKGPsKC6MEKF1qk3YaVITgcmjOSUlsAnsvGooBM81sruBa+dGsAHBO26PLVIHanaKNds="
@@ -1,4 +1,4 @@
# Apache Fineract CN Permitted Feign Client Library
# Apache Fineract CN Permitted Feign Client Library [![Build Status](https://api.travis-ci.com/apache/fineract-cn-permitted-feign-client.svg?branch=develop)](https://travis-ci.com/apache/fineract-cn-permitted-feign-client)

This project provides secured access to other services via Feign. For this it uses anubis and identity to provide refresh and access tokens transparently.

@@ -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'
@@ -66,14 +67,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 ("service-boot")
version project.version
version project.findProperty('externalVersion') ?: project.version
}
}
}
@@ -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"
}


@@ -56,7 +57,7 @@ publishing {
from components.java
groupId project.group
artifactId project.name
version project.version
version project.findProperty('externalVersion') ?: project.version
}
}
}
@@ -46,6 +46,15 @@ task publishToMavenLocal {
dependsOn publishComponentTestToMavenLocal
}

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

task licenseFormat {
group 'all'
dependsOn gradle.includedBuild('api').task(':licenseFormat')
@@ -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'
@@ -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'
@@ -68,7 +69,7 @@ publishing {
from components.java
groupId project.group
artifactId project.name
version project.version
version project.findProperty('externalVersion') ?: project.version
}
}
}
@@ -45,6 +45,7 @@ tasks.withType(JavaCompile) {
repositories {
jcenter()
mavenLocal()
maven { url 'https://mifos.jfrog.io/mifos/libs-snapshot/' }
}

configurations {
@@ -80,6 +81,22 @@ jar {
from sourceSets.main.allSource
}

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', 'libraryPublication', '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 d7ad870

Please sign in to comment.