parsing pipeline files to CST or AST

14 views
Skip to first unread message

Aleksandar Kostadinov

unread,
Sep 28, 2020, 6:09:22 PM9/28/20
to jenkins...@googlegroups.com
Hi,

I'd like to obtain some information about pipeline files I have in our
repository. Such information is whether the pipeline is declarative,
whether it defines parameters, list parameter names and similar.

So I'm trying to create a CST or AST that I can scan through to see
certain properties of these pipelines.

After looking at the available options I tried the following:

> groovy:000> parser = SourceUnit.create("some.jenkinsfile", s, /*tolerance*/ 1)
> groovy:000> parser.parse()
===> null
groovy:000> parser.getCST()
===> null
> groovy:000> parser.getConfiguration().getPluginFactory().createParserPlugin().parseCST(parser, new StringReader(s));
===> null

`s` is the string source of the pipeline. Basically parses to nothing.

Can anybody advise me how to do it?

Thank you.
Reply all
Reply to author
Forward
0 new messages