Use environment variable in Jenkins pipeline options{} block
Asked Answered
L

1

6

I'm trying to use an env var in Jenkins' pipeline options {} block, but it seems they aren't extrapolated at that stage. Am I missing something or is it intentional and there's no way to make it work?

Example:

pipeline {
    agent {
        docker {
            image '...'
            label 'docker'
        }
    }
    environment {
        MAGIC_APP_NAME = "xxx"
        MAGIG_APP_ID = "yyy"
    }
    options {
        connection: gitLabConnection("GitLab-${env.MAGIC_APP_ID}")
    }
}
Leonelleonelle answered 5/11, 2019 at 17:57 Comment(2)
Hi, did you manage to resolve that issue? I am facing the same scenario and looking for a solution.Fanya
@Fanya To be completely honest - I have no ideas, been quite a long time ago, previous life :) Don't have access to that code anymore unfortunately.Leonelleonelle
B
0

Apparently, options section is executed before any environment section.

Brendabrendan answered 8/8, 2024 at 2:19 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.