Merge pull request #275 from Codearte/tech/snapshotUpload

Automatic snapshots upload to Nexus
This commit is contained in:
Marcin Zajączkowski
2016-05-15 11:30:30 +02:00
5 changed files with 69 additions and 6 deletions

View File

@@ -9,8 +9,20 @@ before_install:
- "cp -r stub-runner/stub-runner-spring/src/test/resources/m2repo/repository/io/codearte/accurest/stubs $HOME/.m2/repository/io/codearte/accurest/"
jdk:
- oraclejdk7
- oraclejdk8
install: ./gradlew assemble
script: ./gradlew clean check funcTest install --stacktrace --continue && jdk_switcher use oraclejdk8 && ./scripts/runTests.sh
install: ./gradlew assemble -s
script: ./gradlew check funcTest install -s --continue && jdk_switcher use oraclejdk8 && ./scripts/runTests.sh && jdk_switcher use $TRAVIS_JDK_VERSION && ./gradlew uploadSnapshotArchives -x check -s
matrix:
include:
# Automatic snapshot release only in Java 7 build
- jdk: oraclejdk7
env:
- DO_RELEASE=true
env:
global:
- secure: NbEQ9t5nGKW0LKmOSV4rTiEbYJARM2rynQBdSXkoILbp+nNaCD6uN41tUu8HrjgbjUDMepFUU+hmGQ47Q2vz5L3NzvW+oHBLgrIu6uAimpdR8qyBE899MBKPE19LsvUOeE9B9TydJgYlY+UEYgxwssUwxsN0RqyY4EErQWMNC8k=
- secure: zCjkMhjF5TbZehNmOK7EV68J35tuc0etWG/ia0eVTjgIv2kp9islJZ3+Jm/gDgkcv2Ydq3oAU2jFbVkUPSSstV3L5KANsighm2qn9tVzRrbTCfM55zcBhnoE0oZHTPNrLoScz0X5sM8Xuvi6ChjGf+lqAxnFW6tFMjx+1uhUIXU=

View File

@@ -5,7 +5,7 @@ buildscript {
if (project.hasProperty('fatJar')) jcenter()
}
dependencies {
classpath "pl.allegro.tech.build:axion-release-plugin:1.3.4"
classpath "pl.allegro.tech.build:axion-release-plugin:1.3.2"
classpath "com.bmuschko:gradle-nexus-plugin:2.3"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
if (project.hasProperty('fatJar')) classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
@@ -36,6 +36,8 @@ nexusStaging {
stagingProfileId = '93c08fdebde1ff'
}
apply from: "$rootDir/gradle/releaseRoot.gradle"
subprojects {
apply plugin: 'groovy'
apply from: "$rootDir/gradle/release.gradle"
@@ -211,4 +213,5 @@ buildscript {
}
}
apply plugin: "com.palantir.idea-test-fix"
apply plugin: "com.palantir.idea-test-fix"

View File

@@ -29,6 +29,19 @@ dependencies {
}
----
====== Snapshot versions
Add the additional snapshot repository to your build.gradle to use snapshot versions which are automatically uploaded after every successful build:
[source,groovy,indent=0]
----
repositories {
(...)
//Required only for SNAPSHOT versions
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
----
===== Add maven plugin
[source,xml,indent=0]
@@ -375,4 +388,4 @@ Such tree will cause Accurest generating Wiremock's scenario with name `scenario
- logout marked as `Step2` which will close the scenario.
More details about Wiremock scenarios can be found under [http://wiremock.org/stateful-behaviour.html](http://wiremock.org/stateful-behaviour.html)
Accurest will also generate tests with guaranteed order of execution.
Accurest will also generate tests with guaranteed order of execution.

View File

@@ -38,3 +38,22 @@ modifyPom {
uploadArchives.dependsOn { check }
task uploadSnapshotArchives {
if (shouldUploadSnapshotArchives) {
dependsOn { uploadArchives }
}
onlyIf { shouldUploadSnapshotArchives }
}
//for Travis to leverage secure variables
project.ext {
if (!hasProperty('nexusUsername') && System.env.NEXUS_USERNAME) {
nexusUsername = System.env.NEXUS_USERNAME
}
if (!hasProperty('nexusPassword') && System.env.NEXUS_PASSWORD) {
nexusPassword = System.env.NEXUS_PASSWORD
}
}

16
gradle/releaseRoot.gradle Normal file
View File

@@ -0,0 +1,16 @@
assert project == rootProject
project.ext {
isSnapshot = project.version.endsWith("-SNAPSHOT")
currentBranch = System.env.TRAVIS_BRANCH
isPr = !isNullOrFalse(System.env.TRAVIS_PULL_REQUEST)
doRelease = !isNullOrFalse(System.env.DO_RELEASE)
shouldUploadSnapshotArchives = isSnapshot && currentBranch == 'master' && !isPr && doRelease
}
logger.lifecycle("Automatic snapshot release: {} (isSnapshot: {}, currentBranch: {}, isPr: {}, doRelease: {})", shouldUploadSnapshotArchives, isSnapshot, currentBranch, isPr, doRelease)
private boolean isNullOrFalse(def env) {
env == null || env == "false" || (env instanceof Boolean && !env)
}