reportportal / agent-net-nunit

Report Portal integration point with NUnit 3
Apache License 2.0
21 stars 10 forks source link

Allow overrides of ReportPortal.config.json based on environment #67

Closed xadvfh closed 3 years ago

xadvfh commented 3 years ago

I would like to configure ReportPortal.config.json with overrides for different environments. For example, the base level ReportPortal.config.json may have default values that I want to change for a different environment. I'm looking for behavior similar to how appsettings.ENV.json is handled.

It would also be nice to have a way to read the config from an existing IConfigurationSection

nvborisenko commented 3 years ago

@xadvfh please review https://github.com/reportportal/commons-net/pull/53, there you can find some more details.

If it doesn't work for you please describe your use case.

xadvfh commented 3 years ago

@nvborisenko it doesn't fit my use case. Here is what i need:

My base config has a specific launch name and description.

When this is run against a specific environment, I want to change the launch name and description.

ReportPortal.config.json:

  "launch": {
    "name": "UI Tests - DEV",
    "description": "Testing Description - DEV",
  }

ReportPortal.config.QA.json:

  "launch": {
    "name": "UI Tests - QA",
    "description": "Testing Description - QA",
  }

These aren't user specific configurations so it's not something that each user needs to configure on their own.

nvborisenko commented 3 years ago

How agent should understand which config file should be used?

xadvfh commented 3 years ago

Is there any way to provide the agent an IConfigurationSection instead of config file?

nvborisenko commented 3 years ago

Small project example would help us to be on the same page, where you represent a problem, and perhaps proposed solution.

Bakanych commented 3 years ago

@xadvfh you can solve this by linking configuration file in your csproj like this:

<ItemGroup>
  <Content Include="ReportPortal.config.$(Configuration).json" Link="ReportPortal.config.json" CopyToOutputDirectory="PreserveNewest" />
<ItemGroup>

Now you should create multiply config files with suffix that matches your project configuration name, e.g. ReportPortal.config.Debug.json, ReportPortal.config.Release.json, etc...

nvborisenko commented 3 years ago

Thanks @Bakanych for the solution. It works at build time.

At the same time configuration properties are allowed to be changed at runtime (via environment variables).

nvborisenko commented 3 years ago

Closing it. Feel free to reopen in case of any unresolved issues.