If your job definition is in a Jenkinsfile whether as a declarative or scripted Pipelines, you can create global or per stage environment vars within the environment block.
The environment vars can be dynamically created as a result of a shell step or groovy script or functions, see below an example of declarative pipeline syntax taken from the documentation here
pipeline {
agent any
environment {
// Using returnStdout
CC = """${sh(
returnStdout: true,
script: 'echo "clang"'
)}"""
// Using returnStatus
EXIT_STATUS = """${sh(
returnStatus: true,
script: 'exit 1'
)}"""
}
stages {
stage('Example') {
environment {
DEBUG_FLAGS = '-g'
}
steps {
sh 'printenv'
}
}
}
}
In your case, you want to retrieve the value of the Name provided in Source code management, which seems not trivial as I saw in the how to get repo name in Jenkins pipeline thread, and in that case the name is extracted from the git url itself but not from the custom name.
if you are using the declarative Pipeline approach I wonder if is possible and would make sense to define some String vars to just hold the custom names of your repos, and use those vars for both, use them as the params value for the checkout step, more info here and on the other hand assign the values of the environment vars within the environment block