Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INFRA-1459] - Initial implementation for the buildJenkinsComponent() step #56

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions vars/buildJenkinsComponent.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env groovy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot comment on the filename, and need to review this more fully some day, but I think this should be named buildComponent.
This would be more consistent with buildPlugin, and like for the plugins where we removed Jenkins because it's contextually obviously Jenkins related, I think this is the same here :).


/**
* Build a component defined by Jenkins parent POM.
* @param params Parameters to be passed
*/
def call(Map params = [:]) {
// These platforms correspond to labels in ci.jenkins.io, see:
// https://github.com/jenkins-infra/documentation/blob/master/ci.adoc
def platforms = params.containsKey('platforms') ? params.platforms : ['linux', 'windows']
def jdkVersions = params.containsKey('jdkVersions') ? params.jdkVersions : [8]
int timeoutMin = params.containsKey('timeoutMin') ? Integer.parseInt(params.timeoutMin) : [8]

Map branches = [:]
for (int i = 0; i < platforms.size(); ++i) {
String label = platforms[i]
for (int j = 0; j < jdkVersions.size(); ++j) {
String jdk = jdkVersions[j]
String stageIdentifier = "${label}${jdkVersions.size() > 1 ? '-' + jdk : ''}"
boolean first = i == 0 && j == 0
branches[label] = {
buildSingle(stageIdentifier, label, jdk, first, timeoutMin)
}
}
}

/* Execute our platforms in parallel */
parallel(branches)
}

/**
* Builds a single configuration of a component.
* @param stageIdentifier Stage identifier for visualization
* @param nodeLabel Node label
* @param jdk JDK to be used, {@code 8} by default
* @param archive If {@code true}, arhive results.
* {@code false} by default
* @param timeoutMin Timeout for the Maven run (in minutes)
* @return nothing
*/
def buildSingle(String stageIdentifier, String nodeLabel, String jdk = 8, boolean archive = false, int timeoutMin = 60) {
node(label) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 Probably you mean nodeLabel

timeout(timeoutMin) {
timestamps {
stage("Checkout (${stageIdentifier})") {
infra.checkout(repo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 repo is not defined

isMaven = fileExists('pom.xml')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this variable? Seems unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, copy-paste leftovers I'd guess

}

stage("Build (${stageIdentifier})") {
infra.runMaven(["--batch-mode", "clean", "install", "-Dmaven.test.failure.ignore=true"], jdk)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add -V (aka --show-versions)

}

stage("Archive (${stageIdentifier})") {
/* Archive the test results */
junit '**/target/surefire-reports/TEST-*.xml'

if (archive) {
archiveArtifacts artifacts: '**/target/**/*.jar'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I would delete this and replace with conditional Incrementals deployment, as done in buildPlugin.groovy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For things like Remoting it may be useful to publish the artifacts. But yes, maybe it should be opt-in (and configurable by YAML?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on it being opt-in, however, I would ask that to be configurable via step param (and overridable in YAML) so that you can Replay and activate that if you need to debug instead of making a PR to modify the YAML file

findbugs pattern: '**/target/findbugsXml.xml'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is findbugs guarded by if (archive)?

Is findbugs actually called?

}
}
}
}
}
}
7 changes: 7 additions & 0 deletions vars/buildJenkinsComponent.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>
Builds a Jenkins component following a standard build/test/archive pattern. See repository description for usage.
</p>

<!--
vim: ft=html
-->