79496784

Date: 2025-03-10 00:09:21
Score: 1.5
Natty:
Report link

This video provided the guidance I was looking for:
https://www.youtube.com/watch?v=KwQDxwZRZiE

And my solution looks like this:

pipeline {
    agent any

    parameters {
        choice( name: 'project_short_code', description: 'The short code for this project', choices: ['foo','bar'])
    }

    stages {
    }
        stage('Clone site code to build envornment') {
            steps {
                script {
                    def projects = readYaml file: "build_scripts/9999-build_properties_for_project_code.yaml"
                    env.our_project_repo = projects.project_code."${project_short_code}".our_project_repo
                    env.site_deploy_target = projects.project_code."${project_short_code}".site_deploy_target
                }
                dir("./${env.site_deploy_target}") {
                    git branch: "${site_tag}", credentialsId: "${ssh_credentials}", url: "${env.our_project_repo}" 
                }
            }
        }
    }
}

Apparently, an assignment to an env.FOO requires no def keyword, and, at least in the same context, can be accessed as ${env.FOO}.

Reasons:
  • Blacklisted phrase (1): youtube.com
  • Blacklisted phrase (1): This video
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Hugh Esco