Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from synopsys-arc-oss/tool-versions
[FIXED JENKINS-18772] - Versions support (no proper propagation to Environment)
- Loading branch information
Showing
15 changed files
with
320 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/synopsys/arc/jenkinsci/plugins/customtools/versions/ToolVersionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2013 Oleg Nenashev <nenashev@synopsys.com>, Synopsys 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 com.synopsys.arc.jenkinsci.plugins.customtools.versions; | ||
|
||
import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition; | ||
import com.synopsys.arc.jenkinsci.plugins.customtools.Messages; | ||
import hudson.Extension; | ||
import hudson.model.AbstractDescribableImpl; | ||
import hudson.model.Descriptor; | ||
import java.io.Serializable; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* Class implements support of versions for custom tools | ||
* @author Oleg Nenashev <nenashev@synopsys.com>, Synopsys Inc. | ||
* @since 0.4 | ||
*/ | ||
public class ToolVersionConfig extends AbstractDescribableImpl<ToolVersionConfig> | ||
implements Serializable | ||
{ | ||
public static final ToolVersionConfig DEFAULT = null; | ||
ExtendedChoiceParameterDefinition versionsListSource; | ||
|
||
@DataBoundConstructor | ||
public ToolVersionConfig(ExtendedChoiceParameterDefinition versionsListSource) { | ||
this.versionsListSource = versionsListSource; | ||
} | ||
|
||
public ExtendedChoiceParameterDefinition getVersionsListSource() { | ||
return versionsListSource; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<ToolVersionConfig> { | ||
@Override | ||
public String getDisplayName() { | ||
return Messages.Versions_ToolVersionConfig_DisplayName(); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/synopsys/arc/jenkinsci/plugins/customtools/versions/ToolVersionHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2013 Oleg Nenashev <nenashev@synopsys.com>, Synopsys 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 com.synopsys.arc.jenkinsci.plugins.customtools.versions; | ||
|
||
import com.cloudbees.jenkins.plugins.customtools.CustomTool; | ||
import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition; | ||
import hudson.tools.ToolInstallation; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
/** | ||
* Provides helper for toll versions handling. | ||
* @author Oleg Nenashev <nenashev@synopsys.com>, Synopsys Inc. | ||
* @since 0.4 | ||
*/ | ||
public class ToolVersionHelper { | ||
public static ExtendedChoiceParameterDefinition getDefaultVersionDescr(String toolName) { | ||
return new ExtendedChoiceParameterDefinition( | ||
getDefaultVersionVariableName(toolName), | ||
ExtendedChoiceParameterDefinition.PARAMETER_TYPE_TEXT_BOX, | ||
"default", null, null, | ||
"default", null, null, | ||
false, 1, "Default version stub" | ||
); | ||
} | ||
|
||
public static String getDefaultVersionVariableName(String toolName) { | ||
return toolName.toUpperCase().replaceAll("\\s+", "_"); | ||
} | ||
|
||
public static ExtendedChoiceParameterDefinition getVersionDescr(String toolName) { | ||
CustomTool.DescriptorImpl tools = ToolInstallation.all().get(CustomTool.DescriptorImpl.class); | ||
CustomTool tool = tools.byName(toolName); | ||
return tool.hasVersions() ? tool.getToolVersion().getVersionsListSource() : getDefaultVersionDescr(toolName); | ||
} | ||
|
||
/** | ||
* Gets list of versioned tools. | ||
* @return List of tools, which have versions specified | ||
*/ | ||
public static List<CustomTool> getAllVersionedTools() { | ||
CustomTool.DescriptorImpl tools = ToolInstallation.all().get(CustomTool.DescriptorImpl.class); | ||
List<CustomTool> res = new LinkedList<CustomTool>(); | ||
for (CustomTool tool : tools.getInstallations()) { | ||
if (tool.hasVersions()) { | ||
res.add(tool); | ||
} | ||
} | ||
return res; | ||
} | ||
} |
Oops, something went wrong.