Skip to content

Commit 5bcd897

Browse files
committed
Add new public object2Groovy method for use in other contexts.
Specifically, I'm going to be consuming this in Declarative for a Declarative-specific "directive generator" like the Snippet Generator, but for Declarative directives like `options`, `triggers`, `when`, etc. There'll eventually be a followup PR once that has been implemented in Declarative to add a link to the Directive Generator or whatever we end up calling it to the Pipeline Syntax sidepanel.jelly (conditionally - i.e., if a new enough version of Declarative is installed) but there's no point in doing that yet since I can't actually implement it without this method being public. =)
1 parent b3d7ea3 commit 5bcd897

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/main/java/org/jenkinsci/plugins/workflow/cps/Snippetizer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ static String step2Groovy(Step s) throws UnsupportedOperationException {
7979
return object2Groovy(new StringBuilder(), s, false).toString();
8080
}
8181

82+
/**
83+
* Publicly accessible version of {@link #object2Groovy(StringBuilder, Object, boolean)} that translates an object into
84+
* the equivalent Pipeline Groovy string.
85+
*
86+
* @param o The object to translate.
87+
* @return A string translation of the object.
88+
*/
89+
public static String object2Groovy(Object o) throws UnsupportedOperationException {
90+
return object2Groovy(new StringBuilder(), o, false).toString();
91+
}
92+
8293
/**
8394
* Renders the invocation syntax to re-create a given object 'o' into 'b'
8495
*

0 commit comments

Comments
 (0)