I'm looking to expand macros in a managed configuration file.

It's sort of doable if you jump through hoops now by doing the following:

* Define a managed configuration file using the config-file-provider
* Use the credential-binding-plugin to bind credentials in the job wrapper
* Add a build step that adds the managed configuration file with the option 
to "Expand All" checked

You end up with the file with all tokens expanded.

While this works, it's a sub-optimal workflow for how my team utilizes 
managed configuration files and also manages credentials and job templates 
(we use Jenkins Job Builder for templetized free-style jobs with a large 
library of custom macros and templates)

We want to provide a way for our communities to start managing their 
configuration files more directly using JCasC. The issue with that is that 
we have several files that would require this style of job design which 
would end up requiring us to rewrite well over 50% of our library to 
accommodate this workflow.

So, I've taken it upon myself to extend the config-file-provider to have a 
managed file type that can bind the credentials at definition time to 
macros and auto-expand them when rendering to disk. It's similar to a file 
type that already exists in the plugin, but we need it to be more 
controllable in how it renders out.

That all being said, I did finally manage to figure out how to do this 
myself just this morning by creating my own custom extension of that 
DataBoundTokenMacro. I'm working through some additional logistics of it 
now before I push my PR against config-file-provider.

-Andy-

On Friday, October 2, 2020 at 12:48:12 PM UTC-7 slide wrote:

> Are you just wanting token-macro to expand tokens in a string, or is there 
> more to what you want to do?
>
> On Fri, Oct 2, 2020 at 11:37 AM Andrew Grimberg <
> [email protected]> wrote:
>
>> I'm trying to extend the config-file-provider in support of
>> https://issues.jenkins-ci.org/browse/JENKINS-43204
>>
>> My thoughts are to utilize the token-macro plugin to do the expansion,
>> especially since it's already a dependency of the config-file-provider
>>
>> Unfortunately, I'm not a strong Java developer. I work mostly in Perl
>> and a little bit of Python so I feel I'm failing to figure out how to do
>> this correctly. I see no way to instantiate a TokenMacro (or
>> DataBoundTokenMacro) object with a key / value pair such that I can
>> create a List<TokenMacro> to pass to TokenMacro.expand to do the actual
>> work.
>>
>> My intent is to either extend the custom file type itself to support
>> defined credentials that get automatically expanded in the configuration
>> file, or a brand new file type that does this.
>>
>> At this point, I've basically cloned the properties file type which
>> allows me to define tokenized credentials and just write them back out
>> to the file when the file gets rendered to disk. Now I'm trying to take
>> the next step and actually convert those into something that TokenMacro
>> can then expand for me in the defined file but as I said, I'm failing to
>> figure out how instantiate the object.
>>
>> If I'm going about this all wrong, I would love to know that too, but
>> this seems like it should be fairly straight forward to me to leverage 
>> this.
>>
>> -Andy-
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-dev/40f71460-348d-2cca-17a1-96f10a325020%40linuxfoundation.org
>> .
>>
>
>
> -- 
> Website: http://earl-of-code.com
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/f1a4d4b4-6e7c-4ef8-be4c-ac1f766f605fn%40googlegroups.com.

Reply via email to