-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from oleg-nenashev/buildGradlePlugin
[INFRA-2243] - Introduce new buildPluginWithGradle() step and deprecate Gradle Support in buildPlugin()
- Loading branch information
Showing
4 changed files
with
147 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env groovy | ||
|
||
/** | ||
* Simple wrapper step for building a plugin with Gradle. | ||
*/ | ||
def call(Map params = [:]) { | ||
// Faster build and reduces IO needs | ||
properties([ | ||
durabilityHint('PERFORMANCE_OPTIMIZED'), | ||
buildDiscarder(logRotator(numToKeepStr: '5')), | ||
]) | ||
|
||
def repo = params.containsKey('repo') ? params.repo : null | ||
def failFast = params.containsKey('failFast') ? params.failFast : true | ||
def timeoutValue = params.containsKey('timeout') ? params.timeout : 60 | ||
if (timeoutValue > 180) { | ||
echo "Timeout value requested was $timeoutValue, lowering to 180 to avoid Jenkins project's resource abusive consumption" | ||
timeoutValue = 180 | ||
} | ||
|
||
boolean publishingIncrementals = false | ||
boolean archivedArtifacts = false | ||
Map tasks = [failFast: failFast] | ||
buildPlugin.getConfigurations(params).each { config -> | ||
String label = config.platform | ||
String jdk = config.jdk | ||
String jenkinsVersion = config.jenkins | ||
String javaLevel = config.javaLevel | ||
|
||
String stageIdentifier = "${label}-${jdk}${jenkinsVersion ? '-' + jenkinsVersion : ''}" | ||
|
||
tasks[stageIdentifier] = { | ||
node(label) { | ||
timeout(timeoutValue) { | ||
// Archive artifacts once with pom declared baseline | ||
boolean doArchiveArtifacts = !jenkinsVersion && !archivedArtifacts | ||
if (doArchiveArtifacts) { | ||
archivedArtifacts = true | ||
} | ||
|
||
stage("Checkout (${stageIdentifier})") { | ||
infra.checkout(repo) | ||
} | ||
|
||
stage("Build (${stageIdentifier})") { | ||
if (javaLevel != null) { | ||
echo "WARNING: 'javaLevel' parameter is not supported in buildPluginWithGradle(). It will be ignored" | ||
} | ||
//TODO(oleg-nenashev): Once supported by Gradle JPI Plugin, pass jenkinsVersion | ||
if (jenkinsVersion != null) { | ||
echo "WARNING: 'jenkinsVersion' parameter is not supported in buildPluginWithGradle(). It will be ignored" | ||
} | ||
List<String> gradleOptions = [ | ||
'--no-daemon', | ||
'cleanTest', | ||
'build', | ||
] | ||
String command = "gradlew ${gradleOptions.join(' ')}" | ||
if (isUnix()) { | ||
command = "./" + command | ||
} | ||
infra.runWithJava(command, jdk) | ||
} | ||
|
||
stage("Archive (${stageIdentifier})") { | ||
junit testReports '**/build/test-results/**/*.xml' | ||
|
||
//TODO(oleg-nenashev): Add static analysis results publishing like in buildPlugin() for Maven | ||
|
||
// TODO do this in a finally-block so we capture all test results even if one branch aborts early | ||
if (failFast && currentBuild.result == 'UNSTABLE') { | ||
error 'There were test failures; halting early' | ||
} | ||
if (doArchiveArtifacts) { | ||
archiveArtifacts artifacts: '**/build/libs/*.hpi,**/build/libs/*.jpi', fingerprint: true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
parallel(tasks) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<p> | ||
Builds a Jenkins plugin using Gradle. | ||
</p> | ||
<p> | ||
The implementation follows the standard build/test/archive pattern. | ||
Note that the Gradle flow for Jenkins plugins offers less functionality than the Maven flow, | ||
some key features are not supported: Incrementals - JEP-305, standard static analysis flows, etc. | ||
The current version also does not allow configuring the <code>jenkinsVersion</code>. | ||
</p> | ||
|
||
<p> | ||
<b>Usage.</b> The method can be used in the same way as <code>buildPlugin()</code> for Maven projects. | ||
See the documentation in the README of the Pipeline Library repository. | ||
</p> | ||
|
||
<!-- | ||
vim: ft=html | ||
--> |