org.jenkinsci.plugins.workflow.steps.Step Java Examples

The following examples show how to use org.jenkinsci.plugins.workflow.steps.Step. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PipelineMetadataService.java    From blueocean-plugin with MIT License 6 votes vote down vote up
private @CheckForNull ExportedPipelineStep getStepMetadata(StepDescriptor d) {
    try {
        DescribableModel<? extends Step> model = new DescribableModel<>(d.clazz);

        ExportedPipelineStep step = new ExportedPipelineStep(model, d.getFunctionName(), d);

        // Let any decorators adjust the step properties
        for (ExportedDescribableParameterDecorator decorator : ExtensionList.lookup(ExportedDescribableParameterDecorator.class)) {
            decorator.decorate(step, step.getParameters());
        }

        return step;
    } catch (NoStaplerConstructorException e) {
        // not a normal step?
        return null;
    }
}
 
Example #2
Source File: OpenShiftDeployer.java    From jenkins-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("deploymentConfig")
            && !arguments.containsKey("depCfg"))
        throw new IllegalArgumentException(
                "need to specify deploymentConfig");
    Object depCfg = arguments.get("deploymentConfig");
    if (depCfg == null || depCfg.toString().trim().length() == 0)
        depCfg = arguments.get("depCfg");
    if (depCfg == null || depCfg.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify deploymentConfig");
    OpenShiftDeployer step = new OpenShiftDeployer(depCfg.toString());

    ParamVerify.updateTimedDSLBaseStep(arguments, step);
    return step;
}
 
Example #3
Source File: OpenShiftBuildVerifier.java    From jenkins-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("buildConfig")
            && !arguments.containsKey("bldCfg"))
        throw new IllegalArgumentException(
                "need to specify buildConfig");
    Object bldCfg = arguments.get("buildConfig");
    if (bldCfg == null || bldCfg.toString().trim().length() == 0)
        bldCfg = arguments.get("bldCfg");
    if (bldCfg == null || bldCfg.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify buildConfig");
    OpenShiftBuildVerifier step = new OpenShiftBuildVerifier(
            bldCfg.toString());
    if (arguments.containsKey("checkForTriggeredDeployments")) {
        Object checkForTriggeredDeployments = arguments
                .get("checkForTriggeredDeployments");
        if (checkForTriggeredDeployments != null) {
            step.setCheckForTriggeredDeployments(checkForTriggeredDeployments
                    .toString());
        }
    }

    ParamVerify.updateTimedDSLBaseStep(arguments, step);
    return step;
}
 
Example #4
Source File: OpenShiftServiceVerifier.java    From jenkins-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("serviceName")
            && !arguments.containsKey("svcName"))
        throw new IllegalArgumentException(
                "need to specify serviceName");
    Object svcName = arguments.get("serviceName");
    if (svcName == null || svcName.toString().trim().length() == 0)
        svcName = arguments.get("svcName");
    if (svcName == null || svcName.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify serviceName");
    OpenShiftServiceVerifier step = new OpenShiftServiceVerifier(
            svcName.toString());

    if (arguments.containsKey("retryCount")) {
        Object retryCount = arguments.get("retryCount");
        if (retryCount != null)
            step.setRetryCount(retryCount.toString());
    }

    ParamVerify.updateDSLBaseStep(arguments, step);
    return step;
}
 
Example #5
Source File: OpenShiftCreator.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    Object jsonyaml = arguments.get("yaml");
    if (jsonyaml == null || jsonyaml.toString().trim().length() == 0)
        jsonyaml = arguments.get("json");
    if (jsonyaml == null || jsonyaml.toString().trim().length() == 0)
        jsonyaml = arguments.get("jsonyaml");
    if (jsonyaml == null || jsonyaml.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify json or yaml");
    OpenShiftCreator step = new OpenShiftCreator(jsonyaml.toString());
    ParamVerify.updateDSLBaseStep(arguments, step);
    return step;
}
 
Example #6
Source File: OpenShiftScaler.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("deploymentConfig")
            && !arguments.containsKey("depCfg"))
        throw new IllegalArgumentException(
                "need to specify deploymentConfig");
    Object depCfg = arguments.get("deploymentConfig");
    if (depCfg == null || depCfg.toString().trim().length() == 0)
        depCfg = arguments.get("depCfg");
    if (depCfg == null || depCfg.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify deploymentConfig");
    if (!arguments.containsKey("replicaCount"))
        throw new IllegalArgumentException(
                "need to specif replicaCount");
    OpenShiftScaler step = new OpenShiftScaler(depCfg.toString(),
            arguments.get("replicaCount").toString());

    if (arguments.containsKey("verifyReplicaCount")) {
        Object verifyReplicaCount = arguments.get("verifyReplicaCount");
        if (verifyReplicaCount != null)
            step.setVerifyReplicaCount(verifyReplicaCount.toString());
    }

    ParamVerify.updateTimedDSLBaseStep(arguments, step);
    return step;
}
 
Example #7
Source File: OpenShiftDeleterList.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("types")
            || !arguments.containsKey("keys"))
        throw new IllegalArgumentException(
                "need to specify types, keys, and values");
    OpenShiftDeleterList step = new OpenShiftDeleterList(arguments.get(
            "types").toString(), arguments.get("keys").toString());
    ParamVerify.updateDSLBaseStep(arguments, step);
    return step;
}
 
Example #8
Source File: OpenShiftDeploymentVerifier.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("deploymentConfig")
            && !arguments.containsKey("depCfg"))
        throw new IllegalArgumentException(
                "need to specify deploymentConfig");
    Object depCfg = arguments.get("deploymentConfig");
    if (depCfg == null || depCfg.toString().trim().length() == 0)
        depCfg = arguments.get("depCfg");
    if (depCfg == null || depCfg.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify deploymentConfig");
    OpenShiftDeploymentVerifier step = new OpenShiftDeploymentVerifier(
            depCfg.toString());

    if (arguments.containsKey("replicaCount")) {
        Object replicaCount = arguments.get("replicaCount");
        if (replicaCount != null)
            step.setReplicaCount(replicaCount.toString());
    }
    if (arguments.containsKey("verifyReplicaCount")) {
        Object verifyReplicaCount = arguments.get("verifyReplicaCount");
        if (verifyReplicaCount != null)
            step.setVerifyReplicaCount(verifyReplicaCount.toString());
    }

    ParamVerify.updateTimedDSLBaseStep(arguments, step);
    return step;
}
 
Example #9
Source File: OpenShiftDeleterJsonYaml.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    Object jsonyaml = arguments.get("yaml");
    if (jsonyaml == null || jsonyaml.toString().trim().length() == 0)
        jsonyaml = arguments.get("json");
    if (jsonyaml == null || jsonyaml.toString().trim().length() == 0)
        jsonyaml = arguments.get("jsonyaml");
    if (jsonyaml == null || jsonyaml.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify json or yaml");
    OpenShiftDeleterJsonYaml step = new OpenShiftDeleterJsonYaml(
            jsonyaml.toString());
    ParamVerify.updateDSLBaseStep(arguments, step);
    return step;
}
 
Example #10
Source File: OpenShiftDeleterLabels.java    From jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("types")
            || !arguments.containsKey("keys")
            || !arguments.containsKey("values"))
        throw new IllegalArgumentException(
                "need to specify types, keys, and values");
    OpenShiftDeleterLabels step = new OpenShiftDeleterLabels(arguments
            .get("types").toString(), arguments.get("keys").toString(),
            arguments.get("values").toString());
    ParamVerify.updateDSLBaseStep(arguments, step);
    return step;
}
 
Example #11
Source File: RegistryEndpointStep.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@Override public UninstantiatedDescribable uninstantiate(Step step) throws UnsupportedOperationException {
    RegistryEndpointStep s = (RegistryEndpointStep) step;
    Map<String, Object> args = new TreeMap<>();
    args.put("url", s.registry.getUrl());
    args.put("credentialsId", s.registry.getCredentialsId());
    args.put("toolName", s.toolName);
    args.values().removeAll(Collections.singleton(null));
    return new UninstantiatedDescribable(args);
}
 
Example #12
Source File: RegistryEndpointStep.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@Override public Step newInstance(Map<String, Object> arguments) throws Exception {
    arguments = new HashMap<>(arguments);
    if (arguments.containsKey("url") || arguments.containsKey("credentialsId")) {
        if (arguments.containsKey("registry")) {
            throw new IllegalArgumentException("cannot mix url/credentialsId with registry");
        }
        arguments.put("registry", new DockerRegistryEndpoint((String) arguments.remove("url"), (String) arguments.remove("credentialsId")));
    } else if (!arguments.containsKey("registry")) {
        throw new IllegalArgumentException("must specify url/credentialsId (or registry)");
    }
    return super.newInstance(arguments);
}
 
Example #13
Source File: ExportedPipelineStep.java    From blueocean-plugin with MIT License 4 votes vote down vote up
public ExportedPipelineStep(DescribableModel<? extends Step> model, String functionName,
                            StepDescriptor descriptor) {
    super(model, functionName);
    this.descriptor = descriptor;
}
 
Example #14
Source File: OpenShiftBuilder.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("buildConfig")
            && !arguments.containsKey("bldCfg"))
        throw new IllegalArgumentException(
                "need to specify buildConfig");
    Object bldCfg = arguments.get("buildConfig");
    if (bldCfg == null || bldCfg.toString().trim().length() == 0)
        bldCfg = arguments.get("bldCfg");
    if (bldCfg == null || bldCfg.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify buildConfig");
    OpenShiftBuilder step = new OpenShiftBuilder(bldCfg.toString());
    if (arguments.containsKey("buildName")) {
        Object buildName = arguments.get("buildName");
        if (buildName != null) {
            step.setBuildName(buildName.toString());
        }
    }
    if (arguments.containsKey("checkForTriggeredDeployments")) {
        Object checkForTriggeredDeployments = arguments
                .get("checkForTriggeredDeployments");
        if (checkForTriggeredDeployments != null) {
            step.setCheckForTriggeredDeployments(checkForTriggeredDeployments
                    .toString());
        }
    }
    if (arguments.containsKey("commitID")) {
        Object commitID = arguments.get("commitID");
        if (commitID != null) {
            step.setCommitID(commitID.toString());
        }
    }
    if (arguments.containsKey("showBuildLogs")) {
        Object showBuildLogs = arguments.get("showBuildLogs");
        if (showBuildLogs != null) {
            step.setShowBuildLogs(showBuildLogs.toString());
        }
    }

    // Allow env to be specified as a map: env: [ [ name : 'name1',
    // value : 'value2' ], ... ]
    Object envObject = arguments.get("env");
    if (envObject != null) {
        try {
            ArrayList<NameValuePair> envs = new ArrayList<>();
            List l = (List) envObject;
            for (Object o : l) {
                Map m = (Map) o;
                Object name = m.get("name");
                Object value = m.get("value");
                if (name == null || value == null) {
                    throw new IOException(
                            "Missing name or value in entry: "
                                    + o.toString());
                }
                envs.add(new NameValuePair(name.toString().trim(),
                        value.toString().trim()));
            }
            step.setEnv(envs);
        } catch (Throwable t) {
            throw new UnsupportedOperationException(
                    "Environment variables must be specified as follows: env: [ [ name : 'name1', value : 'value2' ], ... ]. Error: "
                            + t.getMessage());
        }
    }

    ParamVerify.updateTimedDSLBaseStep(arguments, step);
    return step;
}
 
Example #15
Source File: OpenShiftImageTagger.java    From jenkins-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public Step newInstance(Map<String, Object> arguments) throws Exception {
    if (!arguments.containsKey("sourceStream")
            && !arguments.containsKey("destinationStream")
            && !arguments.containsKey("sourceTag")
            && !arguments.containsKey("destinationTag")
            && !arguments.containsKey("destStream")
            && !arguments.containsKey("destTag")
            && !arguments.containsKey("srcTag")
            && !arguments.containsKey("destStream")
            && !arguments.containsKey("srcStream"))
        throw new IllegalArgumentException(
                "need to specify sourceStream, sourceTag, destinationStream, destinationTag");

    Object srcStream = arguments.get("sourceStream");
    Object srcTag = arguments.get("sourceTag");
    Object destStream = arguments.get("destinationStream");
    Object destTag = arguments.get("destinationTag");

    if (srcStream == null || srcStream.toString().trim().length() == 0)
        srcStream = arguments.get("srcStream");
    if (srcTag == null || srcTag.toString().trim().length() == 0)
        srcTag = arguments.get("srcTag");
    if (destStream == null
            || destStream.toString().trim().length() == 0)
        destStream = arguments.get("destStream");
    if (destTag == null || destTag.toString().trim().length() == 0)
        destTag = arguments.get("destTag");

    if (srcStream == null || srcStream.toString().trim().length() == 0
            || srcTag == null || srcTag.toString().trim().length() == 0
            || destStream == null
            || destStream.toString().trim().length() == 0
            || destTag == null
            || destTag.toString().trim().length() == 0)
        throw new IllegalArgumentException(
                "need to specify sourceStream, sourceTag, destinationStream, destinationTag");

    OpenShiftImageTagger step = new OpenShiftImageTagger(
            srcStream.toString(), srcTag.toString(),
            destStream.toString(), destTag.toString());
    if (arguments.containsKey("alias")) {
        Object alias = arguments.get("alias");
        if (alias != null) {
            step.setAlias(alias.toString());
        }
    }
    if (arguments.containsKey("destinationNamespace")) {
        Object destinationNamespace = arguments
                .get("destinationNamespace");
        if (destinationNamespace != null) {
            step.setDestinationNamespace(destinationNamespace
                    .toString());
        }
    }
    if (arguments.containsKey("destinationAuthToken")) {
        Object destinationAuthToken = arguments
                .get("destinationAuthToken");
        if (destinationAuthToken != null) {
            step.setDestinationAuthToken(destinationAuthToken
                    .toString());
        }
    }

    ParamVerify.updateDSLBaseStep(arguments, step);
    return step;
}