Skip to content

Commit

Permalink
[FIX JENKINS-27499] Don't break tool config page if version metadata …
Browse files Browse the repository at this point in the history
…is missing.
  • Loading branch information
orrc committed Feb 25, 2017
1 parent 2fe68cc commit 207027e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/main/java/org/jenkinsci/plugins/golang/GolangInstaller.java
Expand Up @@ -104,7 +104,12 @@ static GolangInstallable getInstallCandidate(GolangRelease release, String osNam
}

private GolangRelease getConfiguredRelease() {
for (GolangRelease r : ((DescriptorImpl) getDescriptor()).getInstallableReleases()) {
List<GolangRelease> releases = ((DescriptorImpl) getDescriptor()).getInstallableReleases();
if (releases == null) {
return null;
}

for (GolangRelease r : releases) {
if (r.id.equals(id)) {
return r;
}
Expand Down Expand Up @@ -144,7 +149,12 @@ public List<GolangRelease> toList() {
JSONObject root;
try {
root = getData();
if (root == null) {
// JSON file has not yet been downloaded by Jenkins
return null;
}
} catch (IOException e) {
// JSON parsing exception occurred
return null;
}

Expand Down
Expand Up @@ -2,17 +2,18 @@ package org.jenkinsci.plugins.golang

def f = namespace(lib.FormTagLib)

f.entry(title: _("Version"), field: "id") {

def releases = descriptor.installableReleases
if (releases.isEmpty()) {
f.textbox()
} else {
def releases = descriptor.installableReleases
if (releases == null || releases.isEmpty()) {
f.block {
text(_('Go version information has not been downloaded. ' +
'To do so, press "Check now" in the Plugin Manager, or restart Jenkins.'))
}
} else {
f.entry(title: _("Version"), field: "id") {
select(name: ".id") {
releases.each { release ->
f.option(value: release.id, selected: release.id == instance?.id, release.name)
}
}
}

}

0 comments on commit 207027e

Please sign in to comment.