From 59ff104f1cd19626e8a0183bb1c76b2d7bbbf0c9 Mon Sep 17 00:00:00 2001 From: Kees Koffeman Date: Wed, 6 Nov 2019 16:40:11 +0100 Subject: [PATCH] Adds CirclCI Provider --- .../plugin/info/ci/CircleCIProvider.groovy | 45 +++++++++++++++++++ .../ci/ContinuousIntegrationInfoPlugin.groovy | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/main/groovy/nebula/plugin/info/ci/CircleCIProvider.groovy diff --git a/src/main/groovy/nebula/plugin/info/ci/CircleCIProvider.groovy b/src/main/groovy/nebula/plugin/info/ci/CircleCIProvider.groovy new file mode 100644 index 0000000..3066e0f --- /dev/null +++ b/src/main/groovy/nebula/plugin/info/ci/CircleCIProvider.groovy @@ -0,0 +1,45 @@ +/* + * Copyright 2018-2019 Netflix, Inc. + * + * Licensed 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 nebula.plugin.info.ci + +import org.gradle.api.Project + +class CircleCIProvider extends AbstractContinuousIntegrationProvider { + @Override + boolean supports(Project project) { + getEnvironmentVariable('CIRCLECI') + } + + @Override + String calculateHost(Project project) { + return hostname() + } + + @Override + String calculateJob(Project project) { + getEnvironmentVariable("CIRCLE_JOB") + } + + @Override + String calculateBuildNumber(Project project) { + getEnvironmentVariable("CIRCLE_BUILD_NUM") + } + + @Override + String calculateBuildId(Project project) { + getEnvironmentVariable("CIRCLE_BUILD_NUM") + } +} diff --git a/src/main/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPlugin.groovy b/src/main/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPlugin.groovy index e5acfb3..c6d6720 100644 --- a/src/main/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPlugin.groovy +++ b/src/main/groovy/nebula/plugin/info/ci/ContinuousIntegrationInfoPlugin.groovy @@ -34,7 +34,7 @@ class ContinuousIntegrationInfoPlugin implements Plugin, InfoCollectorP void apply(Project project) { this.project = project - providers = [new DroneProvider(), new GitlabProvider(), new JenkinsProvider(), new TravisProvider(), new UnknownContinuousIntegrationProvider()] as List + providers = [new CircleCIProvider(), new DroneProvider(), new GitlabProvider(), new JenkinsProvider(), new TravisProvider(), new UnknownContinuousIntegrationProvider()] as List selectedProvider = findProvider() extension = project.extensions.create('ciinfo', ContinuousIntegrationInfoExtension)