def additionalCommandParameters = ''
withCredentials([usernamePassword(credentialsId:nexusRepoCred, passwordVariable:'helmPassword',
usernameVariable:'helmUsername')]) {
additionalCommandParameters = " --username ${helmUsername} --password ${helmPassword}"
}
def helmRepoName = '__' + chartName + '__'
def status = sh (script:"""
set +xe
helm repo add ${helmRepoName} ${helmChartNexusUrl} ${additionalCommandParameters}
""",
returnStdout:true).trim()
if (!status.contains('has been added to your repositories')) {
print("${stepName} Failed to run command: helm repo add ${helmRepoName} ${helmChartNexusUrl} ${additionalCommandParameters}")
throw new Exception("${stepName} Failed to run command: helm repo add ${helmRepoName} ${helmChartNexusUrl} ${additionalCommandParameters}")
}
print("${stepName} helm repo [${helmChartNexusUrl}] added successfully")