Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-49469] Add support for managed file configured in a folder.
- Loading branch information
Showing
16 changed files
with
122 additions
and
83 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
60 changes: 60 additions & 0 deletions
60
src/main/java/jenkins/plugins/nodejs/NodeJSDescriptorUtils.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,60 @@ | ||
package jenkins.plugins.nodejs; | ||
|
||
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
import org.jenkinsci.lib.configprovider.model.Config; | ||
import org.jenkinsci.plugins.configfiles.ConfigFiles; | ||
|
||
import hudson.model.ItemGroup; | ||
import hudson.util.FormValidation; | ||
import hudson.util.ListBoxModel; | ||
import jenkins.plugins.nodejs.configfiles.NPMConfig; | ||
import jenkins.plugins.nodejs.configfiles.NPMConfig.NPMConfigProvider; | ||
import jenkins.plugins.nodejs.configfiles.VerifyConfigProviderException; | ||
|
||
/*package*/ final class NodeJSDescriptorUtils { | ||
|
||
private NodeJSDescriptorUtils() { | ||
} | ||
|
||
/** | ||
* Get all NPMConfig defined for the given context. | ||
* | ||
* @param context the context where lookup the config files | ||
* @return a collection of user npmrc files found for the given context | ||
* always including a system default. | ||
*/ | ||
@Nonnull | ||
public static ListBoxModel getConfigs(@Nullable ItemGroup<?> context) { | ||
ListBoxModel items = new ListBoxModel(); | ||
items.add(Messages.NPMConfig_default(), ""); | ||
for (Config config : ConfigFiles.getConfigsInContext(context, NPMConfigProvider.class)) { | ||
items.add(config.name, config.id); | ||
} | ||
return items; | ||
} | ||
|
||
/** | ||
* Verify that the given configId exists in the given context. | ||
* | ||
* @param context where lookup | ||
* @param configId the identifier of an npmrc file | ||
* @return an validation form for the given npmrc file identifier, otherwise | ||
* returns {@code ok} if the identifier does not exists for the | ||
* given context. | ||
*/ | ||
public static FormValidation checkConfig(@Nullable ItemGroup<?> context, @CheckForNull String configId) { | ||
Config config = ConfigFiles.getByIdOrNull(context, configId); | ||
if (config != null) { | ||
try { | ||
((NPMConfig) config).doVerify(); | ||
} catch (VerifyConfigProviderException e) { | ||
return FormValidation.error(e.getMessage()); | ||
} | ||
} | ||
return FormValidation.ok(); | ||
} | ||
|
||
} |
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
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
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
Oops, something went wrong.