This is an automated email from the ASF dual-hosted git repository. mxm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 01b12f8 add plugin to check if build runs on jenkins new a8fa2d9 Merge pull request #7763: Add plugin to check if build runs on jenkins 01b12f8 is described below commit 01b12f8472746329c4c750801183fb7e999ca2ae Author: Michael Luckey <25622840+adude3...@users.noreply.github.com> AuthorDate: Wed Feb 6 23:44:20 2019 +0100 add plugin to check if build runs on jenkins --- .../apache/beam/gradle/BeamJenkinsPlugin.groovy | 56 ++++++++++++++++++++++ .../org/apache/beam/gradle/BeamModulePlugin.groovy | 6 ++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamJenkinsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamJenkinsPlugin.groovy new file mode 100644 index 0000000..f61b7da --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamJenkinsPlugin.groovy @@ -0,0 +1,56 @@ +/* + * 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. + */ + +package org.apache.beam.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project + +/** + * This plugin checks if build is executed on jenkins server and provides a flag to switch + * configuration accordingly. This is done by check system environment for existence of the + * variables ('HUDSON_HOME', 'BUILD_ID' and 'BUILD_NUMBER'). This behaviour can be overridden + * by setting {@code -PciBuild=false} or {@code -PciBuild=true} respectively. + * + * <p>Example usage: + * + * <pre> + * apply plugin: org.apache.beam.gradle.BeamJenkinsPlugin + * + * tasks.withType(FindBugs) { + * reports { + * html.enabled = !jenkins.isCIBuild + * xml.enabled = jenkins.isCIBuild + * } + * } + * </pre> + */ +class BeamJenkinsPlugin implements Plugin<Project> { + + @Override + void apply(Project project) { + def extension = project.extensions.create('jenkins', JenkinsPluginExtension) + extension.isCIBuild = project.findProperty("ciBuild")?.toBoolean() ?: + // try to deduce from system env. if all variables are set, we probably on jenkins + (System.env['HUDSON_HOME'] && System.env['BUILD_ID'] && System.env['BUILD_NUMBER']) + } + + static class JenkinsPluginExtension { + Boolean isCIBuild + } +} diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy index cb41298..bfb8f3e 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -291,6 +291,8 @@ class BeamModulePlugin implements Plugin<Project> { project.version += '-SNAPSHOT' } + project.apply plugin: BeamJenkinsPlugin + // Register all Beam repositories and configuration tweaks Repositories.register(project) @@ -776,8 +778,8 @@ class BeamModulePlugin implements Plugin<Project> { } project.tasks.withType(FindBugs) { reports { - html.enabled = false - xml.enabled = true + html.enabled = !project.jenkins.isCIBuild + xml.enabled = project.jenkins.isCIBuild } } }