Skip to content

Commit

Permalink
Use automated code formatting (#370)
Browse files Browse the repository at this point in the history
* Use parent pom

* Added logging in catch block for exception handling in BuildTriggerConfig.java

* Enable Code Format Checking in Maven Verify

* Check spotless formatting in verify step

* Remove duplicate entry from pom.xml

This reverts commit d850c50.

* Add code formatting to contributing file

Fix formatting errors in the contributing file

* Restore code changes

* Retain forkCount in contributing guide

---------

Co-authored-by: Mark Waite <[email protected]>
  • Loading branch information
shivajee98 and MarkEWaite authored Mar 2, 2024
1 parent 8c3ea29 commit f8bfe01
Show file tree
Hide file tree
Showing 64 changed files with 3,347 additions and 3,079 deletions.
34 changes: 29 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ Look for contribution areas in the

## Background

Plugin source code is hosted on https://github.com/jenkinsci/parameterized-trigger-plugin[GitHub].
New feature proposals and bug fix proposals should be submitted as https://help.github.com/articles/creating-a-pull-request[GitHub pull requests].
Your pull request will be evaluated by the https://ci.jenkins.io/job/Plugins/job/parameterized-trigger-plugin/[Jenkins job].
Plugin source code is hosted on [GitHub](https://github.com/jenkinsci/parameterized-trigger-plugin).
New feature proposals and bug fix proposals should be submitted as [GitHub pull requests](https://help.github.com/articles/creating-a-pull-request).
Your pull request will be evaluated by the [Jenkins job](https://ci.jenkins.io/job/Plugins/job/parameterized-trigger-plugin/).

Before submitting your change, please assure that you've added tests to verify your change.
Tests help us assure that we're delivering a reliable plugin, and that we've communicated our intent to other developers as executable descriptions of plugin behavior.
Before submitting your change, please assure that you've added tests which verify your change.

## Code formatting

Source code and pom file formatting is maintained by the `spotless` maven plugin.
Before submitting a pull request, confirm the formatting is correct with:

* `mvn spotless:apply`

## Building and Testing

Expand All @@ -24,11 +30,29 @@ Compile the plugin without running tests using the command:

* `mvn clean -DskipTests verify`

### Reviewing code coverage

Code coverage reporting is available as a maven target.
Please try to improve code coverage with tests when you submit.

* `mvn -P enable-jacoco clean install jacoco:report` to report code coverage

The code coverage report is a set of HTML files that show methods and lines executed.
The following commands will open the `index.html` file in the browser.

* Windows - `start target\site\jacoco\index.html`
* Linux - `xdg-open target/site/jacoco/index.html`
* Gitpod - `cd target/site/jacoco && python -m http.server 8000`

The file will have a list of package names.
Click on them to find a list of class names.

The lines of the code will be covered in three different colors, red, green, and orange.
Red lines are not covered in the tests.
Green lines are covered with tests.

### Spotbugs static analysis

Please don't introduce new spotbugs output.

* `mvn spotbugs:check` to analyze project using https://spotbugs.github.io/[Spotbugs].
Expand Down
116 changes: 59 additions & 57 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand All @@ -8,6 +9,12 @@
<relativePath />
</parent>

<artifactId>parameterized-trigger</artifactId>
<version>${changelist}</version>
<packaging>hpi</packaging>
<name>Jenkins Parameterized Trigger plugin</name>
<url>https://github.com/jenkinsci/parameterized-trigger-plugin</url>

<licenses>
<license>
<name>The MIT License (MIT)</name>
Expand All @@ -16,16 +23,38 @@
</license>
</licenses>

<artifactId>parameterized-trigger</artifactId>
<packaging>hpi</packaging>
<version>${changelist}</version>
<name>Jenkins Parameterized Trigger plugin</name>
<url>https://github.com/jenkinsci/parameterized-trigger-plugin</url>
<scm>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:[email protected]:${gitHubRepo}.git</developerConnection>
<tag>${scmTag}</tag>
<url>https://github.com/${gitHubRepo}</url>
</scm>

<properties>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/parameterized-trigger-plugin</gitHubRepo>
<jenkins.version>2.387.3</jenkins.version>
<spotbugs.effort>Max</spotbugs.effort>
<spotbugs.threshold>Low</spotbugs.threshold>
<spotless.check.skip>false</spotless.check.skip>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.387.x</artifactId>
<version>2543.vfb_1a_5fb_9496d</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>subversion</artifactId>
<artifactId>conditional-buildstep</artifactId>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -50,39 +79,54 @@
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>conditional-buildstep</artifactId>
<artifactId>script-security</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>subversion</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>apache-httpcomponents-client-4-api</artifactId>
<scope>test</scope>
</dependency>
<!-- Workflow plugin imports are used to test compatibility -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<scope>test</scope>
</dependency>
<!-- Workflow plugin imports are used to test compatibility -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<artifactId>workflow-job</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -91,51 +135,17 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.387.x</artifactId>
<version>2543.vfb_1a_5fb_9496d</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<scm>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:[email protected]:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
Expand All @@ -149,12 +159,4 @@
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<properties>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/parameterized-trigger-plugin</gitHubRepo>
<jenkins.version>2.387.3</jenkins.version>
<spotbugs.effort>Max</spotbugs.effort>
<spotbugs.threshold>Low</spotbugs.threshold>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractDescribableImpl;
import hudson.model.TaskListener;

import java.io.IOException;
import java.util.List;

/**
* Generates Build Parameters. These will can be used in the TriggerBuilder to trigger the same projects with many different
* parameters.
*/
public abstract class AbstractBuildParameterFactory extends AbstractDescribableImpl<AbstractBuildParameterFactory> implements ExtensionPoint {
public abstract class AbstractBuildParameterFactory extends AbstractDescribableImpl<AbstractBuildParameterFactory>
implements ExtensionPoint {
/**
* Let N be the length of the list returned by this method, and each item in this list X1, X2, X3, ... XN.
*
Expand All @@ -24,14 +24,14 @@ public abstract class AbstractBuildParameterFactory extends AbstractDescribableI
* The build which the parameterized trigger is configured and executing.
* @param listener
* Connected to the build output.
*
*
* @return can be empty but never null.
*/
public abstract List<AbstractBuildParameters> getParameters(AbstractBuild<?,?> build, TaskListener listener)
public abstract List<AbstractBuildParameters> getParameters(AbstractBuild<?, ?> build, TaskListener listener)
throws IOException, InterruptedException, AbstractBuildParameters.DontTriggerException;

@Override
public AbstractBuildParameterFactoryDescriptor getDescriptor() {
return (AbstractBuildParameterFactoryDescriptor)super.getDescriptor();
return (AbstractBuildParameterFactoryDescriptor) super.getDescriptor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public AbstractBuildParameterFactoryDescriptor(Class<? extends AbstractBuildPara
super(clazz);
}

public AbstractBuildParameterFactoryDescriptor() {
}
public AbstractBuildParameterFactoryDescriptor() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import hudson.model.Queue;
import hudson.model.Queue.Task;
import hudson.model.TaskListener;

import java.io.IOException;

/**
Expand All @@ -20,7 +19,8 @@
*
* @see Queue#schedule(Task, int, Action...)
*/
public abstract class AbstractBuildParameters extends AbstractDescribableImpl<AbstractBuildParameters> implements ExtensionPoint {
public abstract class AbstractBuildParameters extends AbstractDescribableImpl<AbstractBuildParameters>
implements ExtensionPoint {

/**
*
Expand All @@ -29,13 +29,13 @@ public abstract class AbstractBuildParameters extends AbstractDescribableImpl<Ab
* @param listener
* Connected to the in-progress build of the {@code build} parameter.
*/
public abstract Action getAction(AbstractBuild<?,?> build, TaskListener listener)
public abstract Action getAction(AbstractBuild<?, ?> build, TaskListener listener)
throws IOException, InterruptedException, DontTriggerException;

/**
* Retrieve the build environment from the upstream build
*/
public EnvVars getEnvironment(AbstractBuild<?,?> build, TaskListener listener)
public EnvVars getEnvironment(AbstractBuild<?, ?> build, TaskListener listener)
throws IOException, InterruptedException {

CapturedEnvironmentAction capture = build.getAction(CapturedEnvironmentAction.class);
Expand Down
Loading

0 comments on commit f8bfe01

Please sign in to comment.