2

We have a repository with metadata in source format, and we use sfdx and ci job to deploy, some metadata (Named Credentials for this instance) contains some values that are env/org dependant.

For the example above, we need to replace endpoint, username, and password depending on the env/org we are deploying to with CI job.

Is there anything like dotenv for PHP to do that?

<?xml version="1.0" encoding="UTF-8"?>
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
    <allowMergeFieldsInBody>true</allowMergeFieldsInBody>
    <allowMergeFieldsInHeader>false</allowMergeFieldsInHeader>
    <endpoint>https://login.microsoftonline.com/XXXXXXXXXXXXXXXXXXXXXX/oauth2/token</endpoint>
    <generateAuthorizationHeader>false</generateAuthorizationHeader>
    <label>AZURE_ActiveDirectory</label>
    <principalType>NamedUser</principalType>
    <protocol>Password</protocol>
    <username>XXXXXXXXXXXXXXX</username>
    <password>XXXXXXXXXXXXXXX</password>
</NamedCredential>
1
  • Don't know about any tool to do this. But I'd remove the named credentials from VCS as it is contains secrets and put them in .gitignore. Instead develop some script to create the named credentials in the target org (probably using SOAP API).
    – ondrakr
    Apr 22, 2022 at 17:59

1 Answer 1

2

I found a workaround, i use .env files to store environement variables and i use a GitHub Workflow to substitute values in the metadata files, passwords/usernames/and tokens are stored as GitHub secrets and substituted also during deployment like env variables.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .