jobs: added getter for nexus credential ID depending on hostname

Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmüller 2023-06-26 17:04:12 +02:00
parent 758802aadd
commit a9e1cdfc2d
1 changed files with 7 additions and 1 deletions

View File

@ -54,6 +54,11 @@ def getGitCredentialID() {
def serverHostname = sh(returnStdout: true, script: "hostname | cut -d '_' -f1").trim()
return ("${serverHostname}" == "nwl") ? 'admin_credentials' : 'gitCredentials'
}
//-----------------------------------------------------------------------------
def getNexusCredentialID() {
def serverHostname = sh(returnStdout: true, script: "hostname | cut -d '_' -f1").trim()
return ("${serverHostname}" == "nwl") ? 'nexus_uploader_credentials' : 'nexusCredentials'
}
//-----------------------------------------------------------------------------
@ -333,6 +338,7 @@ def packAndArchiveArtifacts(machine, pkgArchiveName) {
//-----------------------------------------------------------------------------
// deploy an artifact to the Nexus Artifactory
def deployArtifactToNexusArtifactory(artifactPathname, artifactType, groupId, artifactId, version) {
def credentialIdNexus = getNexusCredentialID()
nexusArtifactUploader(
nexusVersion: "${env.NEXUS_VERSION}",
protocol: "${env.NEXUS_PROTOCOL}",
@ -340,7 +346,7 @@ def deployArtifactToNexusArtifactory(artifactPathname, artifactType, groupId, ar
groupId: "${groupId}",
version: "${version}",
repository: "${env.NEXUS_REPOSITORY}",
credentialsId: "nexus_uploader_credentials",
credentialsId: credentialIdNexus,
artifacts: [
[artifactId: "${artifactId}",
classifier: "",