[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Liam Newman stopped work on JENKINS-43911 Change By: Liam Newman Status: In Progress Open Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.181439.149331354.3393.1567191421750%40Atlassian.JIRA.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Jack P edited a comment on JENKINS-43911 Re: Environment variables can't be used in agent configuration [~eplodn1] Thank you! I am eternally greatful. Totally works with docker and azure storage plugin, here's my stackoverflow example fixed as per yours. {code:java}node('master') { stage('Choose Label') { URL_VAR = "${env.registrySelection == "PROD" ? "urlProd.azure.io" : "urlTest.azure.io"}" CREDS_VAR = "${env.registrySelection == "PROD" ? "credsProd" : "credsTest"}" } } pipeline { parameters { choice( name: 'registrySelection', choices: ['TEST', 'PROD'], description: 'Is this a deployment to STAGING or PRODUCTION environment?' ) } agent { docker { image "${URL_VAR}/image:tag" registryUrl "https://${URL_VAR}" registryCredentialsId "${CREDS_VAR}" } } stages{ stage('test'){ steps{ echo "${URL_VAR}" echo "${CREDS_VAR}" } } } }{code} Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Jack P edited a comment on JENKINS-43911 Re: Environment variables can't be used in agent configuration [~eplodn1] Thank you! I am eternally greatful. Totally works with docker and azure storage plugin, here's my stackoverflow example fixed as per yours. {code:java}node('master') { stage('Choose Label') { URL_VAR = "${env.registrySelection == "PROD" ? "urlProd.azure.io" : "urlTest.azure.io"}" CREDS_VAR = "${env.registrySelection == "PROD" ? "credsProd" : "credsTest"}" } } pipeline { parameters { choice( name: 'registrySelection', choices: ['TEST', 'PROD'], description: 'Is this a deployment to STAGING or PRODUCTION environment?' ) } agent { docker { image "${URL_VAR}/image:tag" registryUrl "https://${URL_VAR}" registryCredentialsId "${CREDS_VAR}" } } stages{ stage('test'){ steps{ echo "${URL_VAR}" echo "${CREDS_VAR}" } } } }{code} Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Jack P edited a comment on JENKINS-43911 Re: Environment variables can't be used in agent configuration [~eplodn1] Thank you! I am eternally greatful. Totally works with docker and azure storage plugin, here's my stackoverflow example fixed as per yours. {code:java}node('master') {stage('Choose Label') {URL_VAR = "${env.registrySelection == "PROD" ? "urlProd.azure.io" : "urlTest.azure.io"}"CREDS_VAR = "${env.registrySelection == "PROD" ? "credsProd" : "credsTest"}"}}pipeline {parameters {choice(name: 'registrySelection',choices: ['TEST', 'PROD'],description: 'Is this a deployment to STAGING or PRODUCTION environment?' )}agent {docker {image "${URL_VAR}/image:tag"registryUrl "https://${URL_VAR}" registryCredentialsId "${CREDS_VAR}"}}stages{stage('test'){steps{echo "${URL_VAR}"echo "${CREDS_VAR}"}}}}{code} Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Jack P commented on JENKINS-43911 Re: Environment variables can't be used in agent configuration efo plo Thank you! I am eternally greatful. Totally works with docker and azure storage plugin, here's my stackoverflow example fixed as per yours. node('master') { stage('Choose Label') { URL_VAR = "${env.registrySelection == "PROD" ? "urlProd.azure.io" : "urlTest.azure.io"}" CREDS_VAR = "${env.registrySelection == "PROD" ? "credsProd" : "credsTest"}" } } pipeline { parameters { choice( name: 'registrySelection', choices: ['TEST', 'PROD'], description: 'Is this a deployment to STAGING or PRODUCTION environment?' ) } agent { docker { image "${URL_VAR}/image:tag" registryUrl "https://${URL_VAR}" registryCredentialsId "${CREDS_VAR}" } } stages{ stage('test'){ steps{ echo "${URL_VAR}" echo "${CREDS_VAR}" } } } } Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title efo plo commented on JENKINS-43911 Re: Environment variables can't be used in agent configuration Jack P We worked around this limitation by implementing a scripted pipeline before declarative: node('master') { stage('Choose Label') { LABEL = 'my_desired_label' // script it anyway you want } } pipeline { agent { node { label "${LABEL}" } } // etc. } Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Jack P commented on JENKINS-43911 Re: Environment variables can't be used in agent configuration I would like to bump interest in this as well recently got diverted here from posting a [similar question on stack overflow|https://stackoverflow.com/questions/55267427/how-can-i-use-different-private-docker-agents-based-on-parameter-in-jenkins-decl.] The solution seems to mean restarting the same environment between stages which feels a bit off and results in me having to merge stages that would be nice to keep separate. Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title efo plo commented on JENKINS-43911 Re: Environment variables can't be used in agent configuration Would also like to have this implemented. We need to dynamically assign a label based on branch, so that branches of Team A run on the resources of that team, etc. We contact Consul for the mapping of branch to label. Currently this is not possible as the label _expression_ is evaluated before the pipeline is run, not at the beginning of the relevant step, so any changes to variables or environment do not affect the node where the step is run. Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Andrew Bayer updated an issue Jenkins / JENKINS-43911 Environment variables can't be used in agent configuration Change By: Andrew Bayer Labels: declarative-variable-and-method-resolution triaged-2018-11 Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Allan Lewis commented on JENKINS-43911 Re: Environment variables can't be used in agent configuration I finally found a workaround for this: registry = 'my-registry' imageRepo = 'my-repo-name' def getImageName(def doCheckout = false) { def treeHash = node { if (doCheckout) checkout scm sh(script: 'git rev-parse HEAD:', returnStdout: true).trim() } "$registry/$imageRepo:$treeHash" } pipeline { agent { label 'docker-builder' } stages { stage('Build & Push Docker Image') { steps { script { docker.build(getImageName()).push() } } } stage('Do Stuff') { agent { docker { image getImageName(true) } } steps { sh 'echo hello' } } } } Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Allan Lewis commented on JENKINS-43911 Re: Environment variables can't be used in agent configuration I have a very similar use case to Caleb Mayeux. This has been in progress for quite a while, can we please have a status update? Add Comment This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Andrew Bayer updated JENKINS-43911 Jenkins / JENKINS-43911 Environment variables can't be used in agent configuration Change By: Andrew Bayer Status: In Review Progress Add Comment This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[JIRA] (JENKINS-43911) Environment variables can't be used in agent configuration
Title: Message Title Caleb Mayeux commented on JENKINS-43911 Re: Environment variables can't be used in agent configuration My use case is that I have a pipeline, and part of the way through it I check out a git repo, and set the latest git commit hash to a variable which is used to tag and push a docker image. Later on I have a stage that uses that image, and thus I need the hash to run the stage using an agent based on that image. The only workaround to do this is to take the stage that checks out the code out of the declarative pipeline and do it before. If there were other steps that had to happen before that, I'd have to take them out of the pipeline too, so at that point I'd be basically just not using declarative pipeline because of this issue. I think being able to dynamically assign agents based on the pipeline is an important and powerful ability, and is something that exists in both scripted pipeline and freestyle jobs (you can assign node/label as a parameter for a freestyle job, and a pipeline of freestyle jobs effectively makes each job the equivalent of a "stage" in pipeline terminology). Add Comment This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.