[JIRA] (JENKINS-60557) Can't set custom variable in customWorkspace

2 views
Skip to first unread message

benfab@gmail.com (JIRA)

unread,
Dec 20, 2019, 6:39:02 AM12/20/19
to jenkinsc...@googlegroups.com
Benoit Fabre created an issue
 
Jenkins / Bug JENKINS-60557
Can't set custom variable in customWorkspace
Issue Type: Bug Bug
Assignee: Unassigned
Components: core, pipeline
Created: 2019-12-20 11:38
Environment: Jenkins version: 2.190.2
OS: CentOS 7.5.1804
Plugins:
Trilead API Plugin (trilead-api): 1.0.5
Oracle Java SE Development Kit Installer Plugin (jdk-tool): 1.4
Structs Plugin (structs): 1.20
Git plugin (git): 4.0.0
SCM API Plugin (scm-api): 2.6.3
Pipeline: Shared Groovy Libraries (workflow-cps-global-lib): 2.15
Pipeline: Step API (workflow-step-api): 2.21
Pipeline: API (workflow-api): 2.38
Timestamper (timestamper): 1.10
Script Security Plugin (script-security): 1.68
Display URL API (display-url-api): 2.3.2
Pipeline: Supporting APIs (workflow-support): 3.3
Token Macro Plugin (token-macro): 2.10
Durable Task Plugin (durable-task): 1.33
Pipeline: Nodes and Processes (workflow-durable-task-step): 2.35
Command Agent Launcher Plugin (command-launcher): 1.4
Ant Plugin (ant): 1.10
JUnit Plugin (junit): 1.28
Mailer Plugin (mailer): 1.29
bouncycastle API Plugin (bouncycastle-api): 2.17
Matrix Project Plugin (matrix-project): 1.14
Branch API Plugin (branch-api): 2.5.5
Resource Disposer Plugin (resource-disposer): 0.14
Workspace Cleanup Plugin (ws-cleanup): 0.38
Credentials Binding Plugin (credentials-binding): 1.20
Pipeline: Milestone Step (pipeline-milestone-step): 1.3.1
JavaScript GUI Lib: jQuery bundles (jQuery and jQuery UI) plugin (jquery-detached): 1.2.1
Email Extension Plugin (email-ext): 2.68
Jackson 2 API Plugin (jackson2-api): 2.10.1
Dashboard View (dashboard-view): 2.12
JavaScript GUI Lib: ACE Editor bundle plugin (ace-editor): 1.1
Pipeline: Multibranch (workflow-multibranch): 2.21
Pipeline: SCM Step (workflow-scm-step): 2.9
File System SCM Plugin (filesystem_scm): 2.1
Pipeline: Groovy (workflow-cps): 2.78
Credentials Plugin (credentials): 2.3.0
Pipeline: Input Step (pipeline-input-step): 2.11
Authentication Tokens API Plugin (authentication-tokens): 1.3
Pipeline: Stage Step (pipeline-stage-step): 2.3
Pipeline: Job (workflow-job): 2.36
GIT server Plugin (git-server): 1.9
Pipeline Graph Analysis Plugin (pipeline-graph-analysis): 1.10
Pipeline: REST API Plugin (pipeline-rest-api): 2.12
JavaScript GUI Lib: Handlebars bundle plugin (handlebars): 1.1.1
WMI Windows Agents Plugin (windows-slaves): 1.5
JavaScript GUI Lib: Moment.js bundle plugin (momentjs): 1.1.1
Docker Commons Plugin (docker-commons): 1.15
Pipeline: Stage View Plugin (pipeline-stage-view): 2.12
Pipeline: Build Step (pipeline-build-step): 2.10
Pipeline: Basic Steps (workflow-basic-steps): 2.18
Plain Credentials Plugin (plain-credentials): 1.5
SSH Credentials Plugin (ssh-credentials): 1.18
Pipeline: Model API (pipeline-model-api): 1.5.0
Pipeline: Declarative Extension Points API (pipeline-model-extensions): 1.5.0
Docker Pipeline (docker-workflow): 1.21
Folders Plugin (cloudbees-folder): 6.10.1
Git client plugin (git-client): 3.0.0
Javadoc Plugin (javadoc): 1.5
Apache HttpComponents Client 4.x API Plugin (apache-httpcomponents-client-4-api): 4.5.10-2.0
PAM Authentication plugin (pam-auth): 1.6
JSch dependency plugin (jsch): 0.1.55.1
Pipeline: Declarative Agent API (pipeline-model-declarative-agent): 1.1.1
Pipeline (workflow-aggregator): 2.6
Pipeline: GitHub Groovy Libraries (pipeline-github-lib): 1.0
Matrix Authorization Strategy Plugin (matrix-auth): 2.5
OWASP Markup Formatter Plugin (antisamy-markup-formatter): 1.6
LDAP Plugin (ldap): 1.21
External Monitor Job Type Plugin (external-monitor-job): 1.7
skip-certificate-check (skip-certificate-check): 1.0
Pipeline: Stage Tags Metadata (pipeline-stage-tags-metadata): 1.5.0
Pipeline: Declarative (pipeline-model-definition): 1.5.0
Lockable Resources plugin (lockable-resources): 2.7
Folder Properties Plugin (folder-properties): 1.0
Simple Theme Plugin (simple-theme-plugin): 0.5.1
Labels: jenkins pipeline pipeline-environment
Priority: Minor Minor
Reporter: Benoit Fabre

Hello,

I would like to use my own environment variable to set the customWorkspace.
Unfortunately, the customWorkspace seems to resolve only built-in Jenkins variables, like JOB_NAME or JOB_BASE_NAME.

See below, the pipeline I am trying to execute:  

pipeline {

  environment {
    CUSTOM_VAR = 'dev1'
  }
  
   agent {
    node {
      label ''
      customWorkspace "/var/lib/jenkins/workspace/${CUSTOM_VAR}"
     }
   }

  stages {

     stage ('Print CUSTOM_VAR') {
       steps {
       sh 'printenv'
       sh 'echo "$CUSTOM_VAR"'
    }
    }
   }
}
 

This pipeline is throwing the error:
[Pipeline] End of Pipelinegroovy.lang.MissingPropertyException: No such property: CUSTOM_VAR for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)

Thank you!

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages