Tabnine Logo
ModelASTPipelineDef
Code IndexAdd Tabnine to your IDE (free)

How to use
ModelASTPipelineDef
in
org.jenkinsci.plugins.pipeline.modeldefinition.ast

Best Java code snippets using org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTPipelineDef (Showing top 20 results out of 315)

origin: jenkinsci/pipeline-model-definition-plugin

/**
 * Helper method to pretty-print the generated Groovy from this and its children.
 *
 * @return An indented string of Groovy, suitable for use in a Jenkinsfile.
 */
public String toPrettyGroovy() {
  return toIndentedGroovy(toGroovy());
}
origin: jenkinsci/pipeline-model-definition-plugin

  @Override
  public int hashCode() {
    int result = super.hashCode();
    result = 31 * result + (getStages() != null ? getStages().hashCode() : 0);
    result = 31 * result + (getPostBuild() != null ? getPostBuild().hashCode() : 0);
    result = 31 * result + (getEnvironment() != null ? getEnvironment().hashCode() : 0);
    result = 31 * result + (getAgent() != null ? getAgent().hashCode() : 0);
    result = 31 * result + (getTools() != null ? getTools().hashCode() : 0);
    result = 31 * result + (getOptions() != null ? getOptions().hashCode() : 0);
    result = 31 * result + (getParameters() != null ? getParameters().hashCode() : 0);
    result = 31 * result + (getTriggers() != null ? getTriggers().hashCode() : 0);
    result = 31 * result + (getLibraries() != null ? getLibraries().hashCode() : 0);
    return result;
  }
}
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void validateAgainstSchema() throws Exception {
  ModelASTPipelineDef root = Converter.urlToPipelineDef(getClass().getResource("/" + configName + ".groovy"));
  assertNotNull(root);
  JSONObject origJson = root.toJSON();
  assertNotNull(origJson);
  ProcessingReport report = Converter.validateJSONAgainstSchema(origJson);
  assertTrue(getErrorReport(origJson, configName, report), report.isSuccess());
}
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void testGroovyToASTToGroovyExecution() throws Exception {
  ModelASTPipelineDef origRoot = Converter.urlToPipelineDef(getClass().getResource("/" + configName + ".groovy"));
  assertNotNull(origRoot);
  String prettyGroovy = origRoot.toPrettyGroovy();
  assertNotNull(prettyGroovy);
  System.err.println("about to set up repo for config " + configName);
  prepRepoWithJenkinsfileFromString(prettyGroovy);
  executeBuild();
}
origin: jenkinsci/pipeline-model-definition-plugin

@Nonnull
public final String toIndentedGroovy(@Nonnull T directive) {
  return ModelASTPipelineDef.toIndentedGroovy(toGroovy(directive));
}
origin: jenkinsci/pipeline-model-definition-plugin

@SuppressWarnings("unused")
@RequirePOST
public HttpResponse doToJson(StaplerRequest req) {
  Jenkins.getInstance().checkPermission(Jenkins.READ);
  JSONObject result = new JSONObject();
  String groovyAsString = req.getParameter("jenkinsfile");
  if (!StringUtils.isEmpty(groovyAsString)) {
    try {
      ModelASTPipelineDef pipelineDef = Converter.scriptToPipelineDef(groovyAsString);
      if (pipelineDef != null) {
        result.accumulate("result", "success");
        result.accumulate("json", pipelineDef.toJSON());
      } else {
        reportFailure(result, "Jenkinsfile content '" + groovyAsString + "' did not contain the 'pipeline' step");
      }
    } catch (Exception e) {
      reportFailure(result, e);
    }
  } else {
    reportFailure(result, "No content found for 'jenkinsfile' parameter");
  }
  return HttpResponses.okJSON(result);
}
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void groovyToASTToGroovyToAST() throws Exception {
  ModelASTPipelineDef origRoot = Converter.urlToPipelineDef(getClass().getResource("/" + configName + ".groovy"));
  assertNotNull(origRoot);
  String prettyGroovy = origRoot.toPrettyGroovy();
  assertNotNull(prettyGroovy);
  ModelASTPipelineDef newRoot = parse(prettyGroovy);
  assertNotNull(newRoot);
  assertEquals(origRoot, newRoot);
}
origin: org.jenkinsci.plugins/pipeline-model-api

  @Override
  public int hashCode() {
    int result = super.hashCode();
    result = 31 * result + (getStages() != null ? getStages().hashCode() : 0);
    result = 31 * result + (getPostBuild() != null ? getPostBuild().hashCode() : 0);
    result = 31 * result + (getEnvironment() != null ? getEnvironment().hashCode() : 0);
    result = 31 * result + (getAgent() != null ? getAgent().hashCode() : 0);
    result = 31 * result + (getTools() != null ? getTools().hashCode() : 0);
    result = 31 * result + (getOptions() != null ? getOptions().hashCode() : 0);
    result = 31 * result + (getParameters() != null ? getParameters().hashCode() : 0);
    result = 31 * result + (getTriggers() != null ? getTriggers().hashCode() : 0);
    result = 31 * result + (getLibraries() != null ? getLibraries().hashCode() : 0);
    return result;
  }
}
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void groovyToASTToJSONToAST() throws Exception {
  ModelASTPipelineDef origRoot = Converter.urlToPipelineDef(getClass().getResource("/" + configName + ".groovy"));
  assertNotNull(origRoot);
  JSONObject origJson = origRoot.toJSON();
  assertNotNull(origJson);
  JSONParser jp = new JSONParser(Converter.jsonTreeFromJSONObject(origJson));
  ModelASTPipelineDef newRoot = jp.parse();
  assertEquals(getJSONErrorReport(jp, configName), 0, jp.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for " + configName, newRoot);
  assertEquals(origRoot, newRoot);
}
origin: jenkinsci/pipeline-model-definition-plugin

  Converter.scriptToPipelineDef(pipelineDef.toPrettyGroovy());
  result.accumulate("result", "success");
  result.accumulate("jenkinsfile", pipelineDef.toPrettyGroovy());
} catch (Exception e) {
  JSONObject jfErrors = new JSONObject();
origin: org.jenkinsci.plugins/pipeline-model-api

if (getStages() != null ? !getStages().equals(that.getStages()) : that.getStages() != null) {
  return false;
if (getPostBuild() != null ? !getPostBuild().equals(that.getPostBuild()) : that.getPostBuild() != null) {
  return false;
if (getEnvironment() != null
    ? !getEnvironment().equals(that.getEnvironment())
    : that.getEnvironment() != null) {
  return false;
if (getAgent() != null ? !getAgent().equals(that.getAgent()) : that.getAgent() != null) {
  return false;
if (getTools() != null ? !getTools().equals(that.getTools()) : that.getTools() != null) {
  return false;
if (getOptions() != null
    ? !getOptions().equals(that.getOptions())
    : that.getOptions() != null) {
  return false;
if (getParameters() != null ? !getParameters().equals(that.getParameters()) : that.getParameters() != null) {
  return false;
if (getLibraries() != null ? !getLibraries().equals(that.getLibraries()) : that.getLibraries() != null) {
  return false;
return getTriggers() != null ? getTriggers().equals(that.getTriggers()) : that.getTriggers() == null;
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void scriptBlockIsAString() throws Exception {
  ModelASTPipelineDef root = parse(getClass().getResource("/simpleScript.groovy"));
  assertNotNull(root);
  JSONObject origJson = root.toJSON();
  assertNotNull(origJson);
  JSONArray stages = origJson.getJSONObject("pipeline").getJSONArray("stages");
  assertNotNull(stages);
  JSONArray branches = stages.getJSONObject(0).getJSONArray("branches");
  assertNotNull(branches);
  JSONArray steps = branches.getJSONObject(0).getJSONArray("steps");
  assertNotNull(steps);
  JSONObject scriptStep  = steps.getJSONObject(0);
  assertNotNull(scriptStep);
  assertEquals("script", scriptStep.getString("name"));
  JSONArray args = scriptStep.getJSONArray("arguments");
  assertNotNull(args);
  JSONObject arg = args.getJSONObject(0);
  assertNotNull(arg);
  JSONObject val = arg.getJSONObject("value");
  assertNotNull(val);
  assertTrue(val.getBoolean("isLiteral"));
  assertEquals("echo \"In a script step\"", val.getString("value"));
}
origin: jenkinsci/pipeline-model-definition-plugin

if (!collectErrors(result, parser.getErrorCollector()) && result.isEmpty()) {
  try {
    Converter.scriptToPipelineDef(pipelineDef.toPrettyGroovy());
    result.accumulate("result", "success");
  } catch (Exception e) {
origin: jenkinsci/pipeline-model-definition-plugin

if (getStages() != null ? !getStages().equals(that.getStages()) : that.getStages() != null) {
  return false;
if (getPostBuild() != null ? !getPostBuild().equals(that.getPostBuild()) : that.getPostBuild() != null) {
  return false;
if (getEnvironment() != null
    ? !getEnvironment().equals(that.getEnvironment())
    : that.getEnvironment() != null) {
  return false;
if (getAgent() != null ? !getAgent().equals(that.getAgent()) : that.getAgent() != null) {
  return false;
if (getTools() != null ? !getTools().equals(that.getTools()) : that.getTools() != null) {
  return false;
if (getOptions() != null
    ? !getOptions().equals(that.getOptions())
    : that.getOptions() != null) {
  return false;
if (getParameters() != null ? !getParameters().equals(that.getParameters()) : that.getParameters() != null) {
  return false;
if (getLibraries() != null ? !getLibraries().equals(that.getLibraries()) : that.getLibraries() != null) {
  return false;
return getTriggers() != null ? getTriggers().equals(that.getTriggers()) : that.getTriggers() == null;
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void jsonToASTToJSON() throws Exception {
  JSONObject origJson = JSONObject.fromObject(fileContentsFromResources("json/" + configName + ".json"));
  assertNotNull("Couldn't parse JSON for " + configName, origJson);
  JSONParser jp = new JSONParser(Converter.jsonTreeFromJSONObject(origJson));
  ModelASTPipelineDef pipelineDef = jp.parse();
  assertEquals(getJSONErrorReport(jp, configName), 0, jp.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for " + configName, pipelineDef);
  assertEquals(origJson, pipelineDef.toJSON());
}
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void testJSONToASTToGroovyExecution() throws Exception {
  JSONObject json = JSONObject.fromObject(fileContentsFromResources("json/" + configName + ".json"));
  assertNotNull("Couldn't parse JSON for " + configName, json);
  JSONParser jp = new JSONParser(Converter.jsonTreeFromJSONObject(json));
  ModelASTPipelineDef origRoot = jp.parse();
  assertEquals(getJSONErrorReport(jp, configName), 0, jp.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for " + configName, origRoot);
  String prettyGroovy = origRoot.toPrettyGroovy();
  assertNotNull(prettyGroovy);
  prepRepoWithJenkinsfileFromString(prettyGroovy);
  executeBuild();
}
origin: jenkinsci/pipeline-model-definition-plugin

@Issue({"JENKINS-41118","JENKINS-43016"})
@Test
public void labelWithOptionsBecomesNode() throws Exception {
  ModelASTPipelineDef origRoot = Converter.urlToPipelineDef(getClass().getResource("/inRelativeCustomWorkspace.groovy"));
  assertNotNull(origRoot);
  JSONObject origJson = origRoot.toJSON();
  assertNotNull(origJson);
  JSONParser jp = new JSONParser(Converter.jsonTreeFromJSONObject(origJson));
  ModelASTPipelineDef newRoot = jp.parse();
  assertEquals(getJSONErrorReport(jp, "inRelativeCustomWorkspace"), 0, jp.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for inRelativeCustomWorkspace", newRoot);
  JSONObject nodeJson = JSONObject.fromObject(fileContentsFromResources("json/inRelativeCustomWorkspace.json"));
  JSONParser nodeParser = new JSONParser(Converter.jsonTreeFromJSONObject(nodeJson));
  ModelASTPipelineDef nodeRoot = nodeParser.parse();
  assertEquals(getJSONErrorReport(nodeParser, "inRelativeCustomWorkspace"),
      0, nodeParser.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for inRelativeCustomWorkspace", nodeRoot);
  assertEquals(nodeRoot, newRoot);
}
origin: jenkinsci/pipeline-model-definition-plugin

@Test
public void jsonToASTToGroovyToAST() throws Exception {
  JSONObject origJson = JSONObject.fromObject(fileContentsFromResources("json/" + configName + ".json"));
  assertNotNull("Couldn't parse JSON for " + configName, origJson);
  JSONParser jp = new JSONParser(Converter.jsonTreeFromJSONObject(origJson));
  ModelASTPipelineDef origRoot = jp.parse();
  assertEquals(getJSONErrorReport(jp, configName), 0, jp.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for " + configName, origRoot);
  String prettyGroovy = origRoot.toPrettyGroovy();
  assertNotNull(prettyGroovy);
  ModelASTPipelineDef newRoot = parse(prettyGroovy);
  assertNotNull(newRoot);
  assertEquals(origRoot, newRoot);
}
origin: jenkinsci/pipeline-model-definition-plugin

  @Test
  public void librariesDirective() throws Exception {
    ModelASTPipelineDef origRoot = Converter.urlToPipelineDef(getClass().getResource("/librariesDirective.groovy"));

    assertNotNull(origRoot);

    JSONObject origJson = origRoot.toJSON();
    assertNotNull(origJson);

    JSONParser jp = new JSONParser(Converter.jsonTreeFromJSONObject(origJson));
    ModelASTPipelineDef newRoot = jp.parse();

    assertEquals(getJSONErrorReport(jp, "librariesDirective"), 0, jp.getErrorCollector().getErrorCount());
    assertNotNull("Pipeline null for librariesDirective", newRoot);

    JSONObject nodeJson = JSONObject.fromObject(fileContentsFromResources("json/librariesDirective.json"));

    JSONParser nodeParser = new JSONParser(Converter.jsonTreeFromJSONObject(nodeJson));
    ModelASTPipelineDef nodeRoot = nodeParser.parse();

    assertEquals(getJSONErrorReport(nodeParser, "librariesDirective"),
        0, nodeParser.getErrorCollector().getErrorCount());
    assertNotNull("Pipeline null for librariesDirective", nodeRoot);

    assertEquals(nodeRoot, newRoot);
  }
}
origin: jenkinsci/pipeline-model-definition-plugin

@Issue("JENKINS-43016")
@Test
public void labelWithEmptyStringBecomesAny() throws Exception {
  ModelASTPipelineDef origRoot = Converter.urlToPipelineDef(getClass().getResource("/agentLabelEmptyString.groovy"));
  assertNotNull(origRoot);
  JSONObject origJson = origRoot.toJSON();
  assertNotNull(origJson);
  JSONParser jp = new JSONParser(Converter.jsonTreeFromJSONObject(origJson));
  ModelASTPipelineDef newRoot = jp.parse();
  assertEquals(getJSONErrorReport(jp, "agentLabelEmptyString"), 0, jp.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for agentLabelEmptyString", newRoot);
  JSONObject anyJson = JSONObject.fromObject(fileContentsFromResources("json/agentAny.json"));
  JSONParser anyParser = new JSONParser(Converter.jsonTreeFromJSONObject(anyJson));
  ModelASTPipelineDef anyRoot = anyParser.parse();
  assertEquals(getJSONErrorReport(anyParser, "agentAny"),
      0, anyParser.getErrorCollector().getErrorCount());
  assertNotNull("Pipeline null for agentAny", anyRoot);
  assertEquals(anyRoot, newRoot);
}
org.jenkinsci.plugins.pipeline.modeldefinition.astModelASTPipelineDef

Javadoc

Represents the parsed pipeline definition for visual pipeline editor. Corresponds to Root.

Most used methods

  • toIndentedGroovy
  • toJSON
  • toPrettyGroovy
    Helper method to pretty-print the generated Groovy from this and its children.
  • getAgent
  • getEnvironment
  • getLibraries
  • getOptions
  • getParameters
  • getPostBuild
  • getStages
  • getTools
  • getTriggers
  • getTools,
  • getTriggers,
  • indent,
  • toGroovy

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSystemService (Context)
  • setScale (BigDecimal)
  • compareTo (BigDecimal)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • JPanel (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now