0

I am very new to use jenkins groovy pipelines. I am trying to find a way to replace environment specific variables in config files, something like

<appender name="AdoNetAppender" type="log4net.Appender.ADONetAppender">
  <connectionString value="#{LogDatabaseConnectionString}" />
</appender>

So during a build step I want to run Variable replacement step which can replace all variables managed by AWS parameter store.

I know there are ways to replace variables using plugins like Envject but it replaces ENV variables defined in jenkins. Other option is to have a parameterized build which can become complex as number of config variables grow.

Possible solution could be to run shell script to replace variables using file.

So, I am looking for options

1) whats the effective way of storing environment specific variables using jenkins pipeline

2) whats the variable replacement strategy to use? e.g. text, content based replacement or other plugins.

Any help is highly appreciated.

Thanks in advance.

prashant
  • 2,181
  • 2
  • 22
  • 37
  • What are you building with? – hakamairi Feb 20 '19 at 08:45
  • Possible duplicate of [how to replace string in file using msbuild?](https://stackoverflow.com/questions/7837644/how-to-replace-string-in-file-using-msbuild) – hakamairi Feb 20 '19 at 08:53
  • @hakamairi link that you have posted has nothing to do with my question. I am looking at what are the standard ways to replace environment specific variable in both .net or non .net e.g. react projects during my jenkins build and deploy pipelines. – prashant Feb 21 '19 at 01:41
  • Hi Prashant, standard way would be to delegate this to the solution that builds the package so it can scan the source files for placeholders. – hakamairi Feb 21 '19 at 06:56

0 Answers0