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

[JENKINS-57903]- Refactor PromotionConditionDescriptor extension Point to make it Pipeline Compatible. #137

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
72aca25
Update Jenkins Core requirement to 2.60.3, use the modern Parent POM
oleg-nenashev May 31, 2019
daa7a82
Fix Jenkinsfile
oleg-nenashev May 31, 2019
0a9e676
Update Jenkins Core to 2.138.x and cleanup Jenkins instance access AP…
oleg-nenashev Jun 1, 2019
084e389
Merge branch 'facelift' of https://github.com/jenkinsci/promoted-buil…
oleg-nenashev Jun 1, 2019
5666eef
More FindBugs cleanup
oleg-nenashev Jun 2, 2019
c3965f0
[JENKINS-57839] - Initial PromotionBadge compatibility code for Jenki…
oleg-nenashev Jun 4, 2019
9c51d9e
[JENKINS-57903]- Refactor PromotionConditionDescriptor class and othe…
dernDren161 Jun 20, 2019
69f69be
Delete README.txt
oleg-nenashev Jun 20, 2019
7317087
Add badges to README
oleg-nenashev Jun 20, 2019
162697b
Remove Contributing from README
oleg-nenashev Jun 20, 2019
68dd6c8
Create CONTRIBUTING.md
oleg-nenashev Jun 20, 2019
fb198ac
Merge pull request #138 from jenkinsci/doc-cleanup
oleg-nenashev Jun 21, 2019
d1ce53d
Maven Fix- For the PromotionConditionDescriptor
dernDren161 Jun 21, 2019
8aa5cec
Stub code for logic review
dernDren161 Jun 22, 2019
bca15f9
Fix tests after ugrading the Jenkins and JTH baseline
oleg-nenashev Jun 22, 2019
e6b87eb
FindBugs: Cleanup unrequired checks in Groovy conditions
oleg-nenashev Jun 22, 2019
bd7af12
Merge pull request #124 from jenkinsci/facelift
oleg-nenashev Jun 22, 2019
4ebbf5e
[maven-release-plugin] prepare release promoted-builds-3.3
oleg-nenashev Jun 22, 2019
64a5bd4
[maven-release-plugin] prepare for next development iteration
oleg-nenashev Jun 22, 2019
307199d
Merge branches
oleg-nenashev Jun 22, 2019
0eeda41
Fix compilation errors in AddPromotionBadge
oleg-nenashev Jun 22, 2019
2f6b639
Restore code from d1ce53de6aa5622899b21768cca4e813c0fab024 by @dernDr…
oleg-nenashev Jun 22, 2019
dd6de8a
Resolve Maven upper bounds issues
oleg-nenashev Jun 22, 2019
8e4fca7
Fix compilation issues in GroovyConditionDescriptor
oleg-nenashev Jun 22, 2019
4fa0b38
PR chnages w.r.t the reviews
dernDren161 Jun 24, 2019
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
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Contributing
Copy link
Member

Choose a reason for hiding this comment

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

The history got messed up after merge by me. Should not impact the delivery

===============

* If you want to add a new feature or to fix a defect, just submit a pull request.
The [pull request template](.github/PULL_REQUEST_TEMPLATE.md) documents usual expectations from pull requests in this project
* Making new releases is covered in [the "Hosting Plugins" wiki page](https://wiki.jenkins-ci.org/display/JENKINS/Hosting+Plugins).
* There are a lot a issues and features that need attention, the JIRA bug tracker is listed on [the wiki page](https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin).
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Builds a module using https://github.com/jenkins-infra/pipeline-library
buildPlugin()
buildPlugin(configurations: buildPlugin.recommendedConfigurations())
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

See the wiki at: <http://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin>
Promoted Builds Plugin
======================

[![Join the chat at https://gitter.im/jenkinsci/promoted-builds-plugin](https://badges.gitter.im/jenkinsci/promoted-builds-plugin.svg)](https://gitter.im/jenkinsci/promoted-builds-plugin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Jenkins Plugin](https://img.shields.io/jenkins/plugin/v/promoted-builds.svg)](https://plugins.jenkins.io/promoted-builds)
[![GitHub release](https://img.shields.io/github/release/jenkinsci/promoted-builds-plugin.svg?label=release)](https://github.com/jenkinsci/promoted-builds-plugin/releases/latest)
[![Jenkins Plugin Installs](https://img.shields.io/jenkins/plugin/i/promoted-builds.svg?color=blue)](https://plugins.jenkins.io/promoted-builds)

This plugin allows you to distinguish good builds from bad builds by
introducing the notion of 'promotion'.Put simply, a promoted build is a
Expand Down Expand Up @@ -179,12 +185,6 @@ freeStyleJob('test-job') {
}
```

## Contributing

* Making new releases is covered in [the "Hosting Plugins" wiki page](https://wiki.jenkins-ci.org/display/JENKINS/Hosting+Plugins).
* If you want to send pull requests or work on some fixes, check [this document](http://jenkins-ci.org/pull-request-greeting).
* There are a lot a issues and features that need attention, the JIRA bug tracker is listed on [the wiki page](https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin).

[1]: https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin
[2]: https://github.com/jenkinsci/promoted-builds-plugin/blob/master/src/main/java/hudson/plugins/promoted_builds/Promotion.java

Expand Down
3 changes: 0 additions & 3 deletions README.txt

This file was deleted.

99 changes: 71 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.4</version>
<version>3.45</version>
</parent>

<artifactId>promoted-builds</artifactId>
<version>3.3-SNAPSHOT</version>
<version>3.4-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>Jenkins promoted builds plugin</name>
<url>https://wiki.jenkins.io/display/JENKINS/Promoted+Builds+Plugin</url>

<properties>
<jenkins.version>1.625.3</jenkins.version>
<java.level>7</java.level>
<jenkins.version>2.138.4</jenkins.version>
<java.level>8</java.level>
<findbugs.effort>Max</findbugs.effort>
<hpi.compatibleSinceVersion>3.0</hpi.compatibleSinceVersion>
</properties>

<developers>
Expand Down Expand Up @@ -61,58 +62,54 @@
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<!-- Significant permission changes. -->
<compatibleSinceVersion>3.0</compatibleSinceVersion>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>3.0</version>
<version>3.2</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>apache-httpcomponents-client-4-api</artifactId>
<version>4.5.3-2.0</version>
<version>4.5.3-2.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mailer</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>com.sonyericsson.hudson.plugins.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>1.25</version>
<version>1.31</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.7</version>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<version>2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -121,6 +118,16 @@
<version>2.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-credentials</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>hudson.plugins</groupId>
<artifactId>project-inheritance</artifactId>
Expand All @@ -130,13 +137,19 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>job-dsl</artifactId>
<version>1.44</version>
<version>1.74</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.26</version>
<version>1.54</version>
</dependency>
<dependency>
<groupId>org.jvnet.hudson</groupId>
Expand Down Expand Up @@ -174,8 +187,38 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.11</version>
<version>1.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.20</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>3.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.32</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.32</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
120 changes: 120 additions & 0 deletions src/main/java/hudson/plugins/promoted_builds/AddPromotionBadge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package hudson.plugins.promoted_builds;

import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.*;
import hudson.tasks.*;
import jenkins.tasks.SimpleBuildStep;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import java.io.IOException;
import java.io.PrintStream;

public class AddPromotionBadge extends Recorder implements SimpleBuildStep {
Copy link
Member

Choose a reason for hiding this comment

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

This code is still in the production scope, needs to be moved


private String boxName = "Promotion Badges";
private boolean gold;
private boolean silver;

@Extension
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();

@DataBoundConstructor
public AddPromotionBadge(String boxName, boolean gold, boolean silver){
this.boxName = boxName;
this.gold = gold;
this.silver = silver;
}

public String getBoxName(){
return boxName;
}

@DataBoundSetter
public void setBoxName(String boxName){
this.boxName = boxName;
}


public boolean getGold(){
return gold;
}

@DataBoundSetter
public void setGold(boolean gold){
this.gold = gold;
}

public boolean getSilver(){
return silver;
}

@DataBoundSetter
public void setSilver(boolean silver){
this.silver = silver;
}

public BuildStepMonitor getRequiredMonitorService(){
return BuildStepMonitor.NONE;
}


@Override
public void perform(Run<?, ?> build, FilePath workspace, Launcher launcher, final TaskListener listener)
throws InterruptedException, IOException {

PrintStream logger = listener.getLogger();
logger.println("Started initialization");

Result buildResult = build.getResult();

if (Result.SUCCESS.equals(buildResult)) {
logger.println("The pipeline build is successful!!");

if(gold == true){
// How to assign actual badge icons??
}

}

String temp;

if(build instanceof AbstractBuild){
EnvVars vars = build.getEnvironment(listener);
vars.overrideAll(((AbstractBuild)build).getBuildVariables());
temp = vars.expand(boxName);
}else{
temp = boxName;
}

logger.println("Starting the pipeline build");
logger.println("Will assign badges once the pipeline build is successful in promotion");

}


public static final class DescriptorImpl extends BuildStepDescriptor<Publisher>{

private DescriptorImpl(){
super(AddPromotionBadge.class);
}

public String getDisplayName(){
return "Add Promotion Badges";
}


@Override
public boolean isApplicable(Class<? extends AbstractProject> a){
return true;
}

}




}
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public List<PromotionProcess> getActiveItems() {
/** @see ItemGroupMixIn#createProjectFromXML */
public PromotionProcess createProcessFromXml(final String name, InputStream xml) throws IOException {
owner.checkPermission(Item.CONFIGURE); // CREATE is ItemGroup-scoped and owner is not an ItemGroup
Jenkins.getInstance().getProjectNamingStrategy().checkName(name);
Jenkins.get().getProjectNamingStrategy().checkName(name);
if (getItem(name) != null) {
throw new IllegalArgumentException(owner.getDisplayName() + " already contains an item '" + name + "'");
}
Expand Down
Loading