@Override @Nonnull public Collection<? extends Action> createFor(@Nonnull WorkflowJob target) { if (target.hasPermission(Item.EXTENDED_READ)) { return Collections.singleton(new DirectiveGenerator()); } else { return Collections.emptySet(); } } }
@Restricted(NoExternalUse.class) public static String mapToClosure(Map<String,?> args) { StringBuilder result = new StringBuilder("{\n"); for (Map.Entry<String,?> arg : args.entrySet()) { if (!(arg.getValue() instanceof String && arg.getValue().equals(""))) { result.append(arg.getKey()).append(" "); if (arg.getValue() instanceof Map) { result.append(mapToClosure((Map<String, ?>) arg.getValue())); } else if (arg.getValue() instanceof UninstantiatedDescribable) { result.append(mapToClosure(((UninstantiatedDescribable) arg.getValue()).getArguments())); } else if (arg.getValue() != null) { result.append(Snippetizer.object2Groovy(arg.getValue())).append("\n"); } } } result.append("}\n"); return result.toString(); }
@Override @Nonnull public List<Descriptor> getDescriptors() { return ExtensionList.lookup(ToolDescriptor.class).stream().filter(t -> t.getInstallations().length > 0 && DirectiveGenerator.getSymbolForDescriptor(t) != null ).collect(Collectors.toList()); }
@Override @Nonnull public String toGroovy(@Nonnull ToolsDirective directive) { StringBuilder result = new StringBuilder("tools {\n"); if (!directive.getTools().isEmpty()) { for (ToolInstallation tool : directive.getToolInstallations()) { result.append(DirectiveGenerator.getSymbolForDescriptor(tool.getDescriptor())).append(" "); result.append(Snippetizer.object2Groovy(tool.getName())).append("\n"); } } else { result.append("// No valid tools specified\n"); } result.append("}\n"); return result.toString(); } }
@Override @Nonnull public Collection<? extends Action> createFor(@Nonnull WorkflowMultiBranchProject target) { if (target.hasPermission(Item.EXTENDED_READ)) { return Collections.singleton(new DirectiveGenerator()); } else { return Collections.emptySet(); } }
} else { result.append(desc.getName()).append(" ").append(DirectiveGenerator.mapToClosure(ud.getArguments()));
@Override @Nonnull public Collection<? extends Action> createFor(@Nonnull OrganizationFolder target) { if (target.getProjectFactories().get(AbstractWorkflowMultiBranchProjectFactory.class) != null && target.hasPermission(Item.EXTENDED_READ)) { return Collections.singleton(new DirectiveGenerator()); } else { return Collections.emptySet(); } } }