Skip to content

Commit

Permalink
Merge pull request #1199 from daspilker/jenkins-2.138
Browse files Browse the repository at this point in the history
increased the minimum supported Jenkins version to 2.138
  • Loading branch information
daspilker authored Sep 3, 2019
2 parents f743063 + 86f890d commit c35fc77
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
master:
image: jenkins/jenkins:2.121.1
image: jenkins/jenkins:2.138.1
ports:
- "8081:8080"
volumes:
Expand Down
1 change: 1 addition & 0 deletions docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins

## Release Notes
* 1.77 (unreleased)
* Increased the minimum supported Jenkins version to 2.138
* Fixed problem with paths on Windows
([JENKINS-53840](https://issues.jenkins-ci.org/browse/JENKINS-53840))
* 1.76 (August 22 2019)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version=1.77-SNAPSHOT
groovyVersion=2.4.11
jenkinsVersion=2.121
jenkinsVersion=2.138
assetPipelineVersion=2.11.6
githubUser=jenkinsci
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package javaposse.jobdsl.plugin;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
Expand Down Expand Up @@ -138,8 +137,6 @@ public ExecuteDslScripts() {
this.ignoreExisting = false;
this.failOnSeedCollision = false;
this.removedJobAction = RemovedJobAction.DISABLE;
this.removedViewAction = RemovedViewAction.IGNORE;
this.lookupStrategy = LookupStrategy.JENKINS_ROOT;
this.additionalClasspath = null;
}

Expand Down Expand Up @@ -318,8 +315,7 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
env.putAll(((AbstractBuild<?, ?>) run).getBuildVariables());
}

Map<String, Object> binding = new HashMap<>();
binding.putAll(env);
Map<String, Object> binding = new HashMap<>(env);
if (additionalParameters != null) {
binding.putAll(additionalParameters);
}
Expand Down Expand Up @@ -364,11 +360,11 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
addJobAction(run, new GeneratedConfigFilesBuildAction(freshConfigFiles));
addJobAction(run, new GeneratedUserContentsBuildAction(freshUserContents));

updateTemplates(run.getParent(), listener, new HashSet<GeneratedJob>(run.getAction(GeneratedJobsBuildAction.class).getModifiedObjects()));
updateGeneratedJobs(run.getParent(), listener, new HashSet<GeneratedJob>(run.getAction(GeneratedJobsBuildAction.class).getModifiedObjects()));
updateGeneratedViews(run.getParent(), listener, new HashSet<GeneratedView>(run.getAction(GeneratedViewsBuildAction.class).getModifiedObjects()));
updateGeneratedConfigFiles(run.getParent(), listener, new HashSet<GeneratedConfigFile>(run.getAction(GeneratedConfigFilesBuildAction.class).getModifiedObjects()));
updateGeneratedUserContents(run.getParent(), listener, new HashSet<GeneratedUserContent>(run.getAction(GeneratedUserContentsBuildAction.class).getModifiedObjects()));
updateTemplates(run.getParent(), listener, new HashSet<>(run.getAction(GeneratedJobsBuildAction.class).getModifiedObjects()));
updateGeneratedJobs(run.getParent(), listener, new HashSet<>(run.getAction(GeneratedJobsBuildAction.class).getModifiedObjects()));
updateGeneratedViews(run.getParent(), listener, new HashSet<>(run.getAction(GeneratedViewsBuildAction.class).getModifiedObjects()));
updateGeneratedConfigFiles(run.getParent(), listener, new HashSet<>(run.getAction(GeneratedConfigFilesBuildAction.class).getModifiedObjects()));
updateGeneratedUserContents(run.getParent(), listener, new HashSet<>(run.getAction(GeneratedUserContentsBuildAction.class).getModifiedObjects()));
}
} catch (RuntimeException e) {
if (!(e instanceof DslException) && !(e instanceof AccessDeniedException)) {
Expand Down Expand Up @@ -604,12 +600,7 @@ private static void logItems(TaskListener listener, String message, Collection<?
}

private static Set<String> getTemplates(Collection<GeneratedJob> jobs) {
Collection<String> templateNames = Collections2.transform(jobs, new Function<GeneratedJob, String>() {
@Override
public String apply(GeneratedJob input) {
return input.getTemplateName();
}
});
Collection<String> templateNames = Collections2.transform(jobs, GeneratedJob::getTemplateName);
return new LinkedHashSet<>(Collections2.filter(templateNames, Predicates.notNull()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package javaposse.jobdsl.plugin;

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.thoughtworks.xstream.io.xml.XppDriver;
Expand Down Expand Up @@ -60,6 +59,7 @@
import static hudson.model.Result.UNSTABLE;
import static hudson.model.View.createViewFromXML;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;

/**
* Manages Jenkins jobs, providing facilities to retrieve and create / update.
Expand Down Expand Up @@ -167,7 +167,7 @@ public void createOrUpdateView(String path, String config, boolean ignoreExistin
String viewBaseName = FilenameUtils.getName(path);
Jenkins.checkGoodName(viewBaseName);
try {
InputStream inputStream = new ByteArrayInputStream(config.getBytes("UTF-8"));
InputStream inputStream = new ByteArrayInputStream(config.getBytes(UTF_8));

ItemGroup parent = lookupStrategy.getParent(project, path);
if (parent instanceof ViewGroup) {
Expand Down Expand Up @@ -365,12 +365,7 @@ public Integer getVSphereCloudHash(String name) {
public void renameJobMatching(final String previousNames, String destination) throws IOException {
final ItemGroup context = lookupStrategy.getContext(project);
Collection<Job> items = Jenkins.get().getAllItems(Job.class);
Collection<Job> matchingJobs = Collections2.filter(items, new Predicate<Job>() {
@Override
public boolean apply(Job topLevelItem) {
return topLevelItem.getRelativeNameFrom(context).matches(previousNames);
}
});
Collection<Job> matchingJobs = Collections2.filter(items, topLevelItem -> topLevelItem.getRelativeNameFrom(context).matches(previousNames));
if (matchingJobs.size() == 1) {
renameJob(matchingJobs.iterator().next(), destination);
} else if (matchingJobs.size() > 1) {
Expand Down Expand Up @@ -514,7 +509,7 @@ private void createNewItem(String path, javaposse.jobdsl.dsl.Item dslItem) {
LOGGER.log(Level.FINE, format("Creating item as %s", config));

try {
InputStream is = new ByteArrayInputStream(config.getBytes("UTF-8"));
InputStream is = new ByteArrayInputStream(config.getBytes(UTF_8));

ItemGroup parent = lookupStrategy.getParent(project, path);
String itemName = FilenameUtils.getName(path);
Expand Down Expand Up @@ -582,8 +577,8 @@ private void renameJob(Job from, String to) throws IOException {
}

@SuppressWarnings("unchecked")
private static <I extends AbstractItem & TopLevelItem> I move(Item item, DirectlyModifiableTopLevelItemGroup destination) throws IOException {
return Items.move((I) item, destination);
private static <I extends AbstractItem & TopLevelItem> void move(Item item, DirectlyModifiableTopLevelItemGroup destination) throws IOException {
Items.move((I) item, destination);
}

private static class JobDslCause extends Cause {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Comparators {
}

private static String getFullDisplayName(View view) {
String ownerDisplayName = view.ownerItemGroup.fullDisplayName
String ownerDisplayName = view.owner.itemGroup.fullDisplayName
ownerDisplayName.length() == 0 ? view.displayName : "${ownerDisplayName} » ${view.displayName}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void check(CNode node) throws ConfiguratorException {
}

@Override
public CNode describe() throws Exception {
public CNode describe() {
return null; // Not relevant here
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void configure(String script) {
}

@Override
public String getScript() throws IOException {
public String getScript() {
return script;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public GeneratedItems[] getTargetComponent(ConfigurationContext context) {

@Nonnull
@Override
@SuppressWarnings("unchecked")
public GeneratedItems[] configure(CNode config, ConfigurationContext context) throws ConfiguratorException {
Map<String, String> env = new HashMap<>(System.getenv());
JenkinsJobManagement management = new JenkinsJobManagement(System.out, env, null, null, LookupStrategy.JENKINS_ROOT);
Expand All @@ -73,7 +72,7 @@ public GeneratedItems[] configure(CNode config, ConfigurationContext context) th
}

@Override
public GeneratedItems[] check(CNode config, ConfigurationContext context) throws ConfiguratorException {
public GeneratedItems[] check(CNode config, ConfigurationContext context) {
return new GeneratedItems[0];
}

Expand All @@ -85,7 +84,7 @@ public List<Configurator<GeneratedItems[]>> getConfigurators(ConfigurationContex

@CheckForNull
@Override
public CNode describe(GeneratedItems[] instance, ConfigurationContext context) throws Exception {
public CNode describe(GeneratedItems[] instance, ConfigurationContext context) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import hudson.model.Label
import hudson.model.ListView
import hudson.model.Project
import hudson.model.Queue
import hudson.model.Result
import hudson.model.Run
import hudson.model.User
import hudson.model.View
Expand Down Expand Up @@ -1283,8 +1282,8 @@ folder('folder-a/folder-b') {
where:
unstableOnDeprecation || result
true || Result.UNSTABLE
false || Result.SUCCESS
true || UNSTABLE
false || SUCCESS
}
def 'unstable or failure on missing plugin'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ class JenkinsJobManagementSpec extends Specification {
FreeStyleProject seedJob = jenkinsRule.createFreeStyleProject('seed')
seedJob.buildersList.add(new ExecuteDslScripts('job("project")'))
jenkinsRule.buildAndAssertSuccess(seedJob)
Jenkins.instance.getItemByFullName('seed').delete()
Jenkins.get().getItemByFullName('seed').delete()
FreeStyleProject seedJob2 = jenkinsRule.createFreeStyleProject('seed2')
AbstractBuild build = seedJob2.scheduleBuild2(0).get()
JobManagement jobManagement = new JenkinsJobManagement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import hudson.model.AbstractBuild
import hudson.model.AbstractProject
import hudson.model.ItemGroup
import hudson.model.View
import hudson.model.ViewGroup
import javaposse.jobdsl.dsl.GeneratedView
import spock.lang.Specification

Expand Down Expand Up @@ -106,10 +107,12 @@ class GeneratedViewsActionSpec extends Specification {
setup:
ItemGroup itemGroup = Mock(ItemGroup)
itemGroup.fullDisplayName >> 'foo'
ViewGroup owner = Mock(ViewGroup)
owner.itemGroup >> itemGroup
views[0].displayName >> 'one'
views[0].ownerItemGroup >> itemGroup
views[0].owner >> owner
views[1].displayName >> 'two'
views[1].ownerItemGroup >> itemGroup
views[1].owner >> owner
buildAction.views >> views
build1.getAction(GeneratedViewsBuildAction) >> buildAction
build2.getAction(GeneratedViewsBuildAction) >> buildAction
Expand Down

0 comments on commit c35fc77

Please sign in to comment.