def generateAuthorizedPypirc (String path) {
  content = """[distutils]
index-servers = pypi
[pypi]
repository: https://artifacts.apollo.stream/repository/pypi-internal/
username: ${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/pypi_nexus', 'gdb-infra-dev', '.username')}
password: ${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/pypi_nexus', 'gdb-infra-dev', '.password')}
"""
  writeFile file: path, text: content
}

def generateCleanPypirc (String path) {
  content = """[distutils]
index-servers = pypi
[pypi]
repository: https://artifacts-internal.apollo.stream/repository/pypi-internal/
"""
  writeFile file: path, text: content
}

def generateAuthorizedMavenConfig (String path) {
  content = """realm=Sonatype Nexus Repository Manager
host=artifacts-internal.delphiplatform.io
user=${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/maven_nexus', 'gdb-infra-dev', '.username')}
password=${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/maven_nexus', 'gdb-infra-dev', '.password')}
"""
  writeFile file: path, text: content
}

def generateAuthorizedMavenSettingsXML (String path) {
  content = """<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">

    <servers>
        <server>
            <id>delphi-nexus</id>
            <username>${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/maven_nexus', 'gdb-infra-dev', '.username')}</username>
            <password>${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/maven_nexus', 'gdb-infra-dev', '.password')}</password>
        </server>
        <server>
            <id>delphi-nexus-snapshots</id>
            <username>${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/maven_nexus', 'gdb-infra-dev', '.username')}</username>
            <password>${utility.getSecretValueByIdAndJsonPath('infra/jenkins/common/maven_nexus', 'gdb-infra-dev', '.password')}</password>
        </server>
    </servers>
</settings>"""
  writeFile file: path, text: content
}
