-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Staging for version increment automation (#1932)
* Version increment automation Signed-off-by: pgodithi <[email protected]> (cherry picked from commit 235d256)
- Loading branch information
1 parent
46fd8a2
commit 39dea26
Showing
2 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -374,3 +374,108 @@ buildDeb { | |
arch = 'all' | ||
archiveName "${packageName}-${version}.deb" | ||
} | ||
|
||
allprojects { | ||
// add a collection to track failedTests | ||
ext.failedTests = [] | ||
|
||
// add a testlistener to all tasks of type Test | ||
tasks.withType(Test) { | ||
afterTest { TestDescriptor descriptor, TestResult result -> | ||
if(result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE){ | ||
failedTests << ["${descriptor.className}::${descriptor.name}"] | ||
} | ||
} | ||
} | ||
|
||
// print out tracked failed tests when the build has finished | ||
gradle.buildFinished { | ||
if(!failedTests.empty){ | ||
println "Failed tests for ${project.name}:" | ||
failedTests.each { failedTest -> | ||
println failedTest | ||
} | ||
println "" | ||
} | ||
} | ||
} | ||
|
||
// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name | ||
afterEvaluate { | ||
ospackage { | ||
packageName = "${name}" | ||
release = isSnapshot ? "0.1" : '1' | ||
version = "${project.version}" - "-SNAPSHOT" | ||
|
||
into '/usr/share/opensearch/plugins' | ||
from(zipTree(bundlePlugin.archivePath)) { | ||
into opensearchplugin.name | ||
} | ||
|
||
user 'root' | ||
permissionGroup 'root' | ||
fileMode 0644 | ||
dirMode 0755 | ||
|
||
requires('opensearch', versions.opensearch, EQUAL) | ||
packager = 'Amazon' | ||
vendor = 'Amazon' | ||
os = 'LINUX' | ||
prefix '/usr' | ||
|
||
license 'ASL-2.0' | ||
maintainer 'OpenSearch <[email protected]>' | ||
url 'https://opensearch.org/downloads.html' | ||
summary ''' | ||
Security plugin for OpenSearch. | ||
Reference documentation can be found at https://opensearch.org/docs/latest/. | ||
'''.stripIndent().replace('\n', ' ').trim() | ||
} | ||
|
||
buildRpm { | ||
arch = 'NOARCH' | ||
dependsOn 'assemble' | ||
finalizedBy 'renameRpm' | ||
task renameRpm(type: Copy) { | ||
from("$buildDir/distributions") | ||
into("$buildDir/distributions") | ||
include archiveName | ||
rename archiveName, "${packageName}-${version}.rpm" | ||
doLast { delete file("$buildDir/distributions/$archiveName") } | ||
} | ||
} | ||
|
||
buildDeb { | ||
arch = 'all' | ||
dependsOn 'assemble' | ||
finalizedBy 'renameDeb' | ||
task renameDeb(type: Copy) { | ||
from("$buildDir/distributions") | ||
into("$buildDir/distributions") | ||
include archiveName | ||
rename archiveName, "${packageName}-${version}.deb" | ||
doLast { delete file("$buildDir/distributions/$archiveName") } | ||
} | ||
} | ||
|
||
task buildPackages(type: GradleBuild) { | ||
tasks = ['build', 'buildRpm', 'buildDeb'] | ||
} | ||
} | ||
|
||
// updateVersion: Task to auto increment to the next development iteration | ||
task updateVersion { | ||
onlyIf { System.getProperty('newVersion') } | ||
doLast { | ||
ext.newVersion = System.getProperty('newVersion') | ||
println "Setting version to ${newVersion}." | ||
// String tokenization to support -SNAPSHOT | ||
ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) { | ||
fileset(dir: projectDir) { | ||
// Include the required files that needs to be updated with new Version | ||
include(name: "bwc-test/build.gradle") | ||
} | ||
} | ||
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true) | ||
} | ||
} |