[JIRA] (JENKINS-61709) Map.get("${var}") returns null

4 views
Skip to first unread message

raphael@hoeser.info (JIRA)

unread,
Mar 27, 2020, 9:46:03 AM3/27/20
to jenkinsc...@googlegroups.com
Raphael Höser created an issue
 
Jenkins / Bug JENKINS-61709
Map.get("${var}") returns null
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2020-03-27 13:45
Environment: Jenkins 2.204.4 LTS
Labels: pipeline jenkins
Priority: Minor Minor
Reporter: Raphael Höser

When accessing a map key via .get() with a var replacement in the key the get operation always returns null.

 

Example snippet:

def map = ["key_identifier": "test"]

def id = "identifier"
def resA = map.get("key_identifier")
print(resA)

def resB = map.get("key_${id}")
print(resB)
 
This will return in the output:
Test
null

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

raphael@hoeser.info (JIRA)

unread,
Mar 30, 2020, 9:19:03 AM3/30/20
to jenkinsc...@googlegroups.com
Raphael Höser commented on Bug JENKINS-61709
 
Re: Map.get("${var}") returns null

Just in case someone stumbles upon this:
you can use map["key_${id}"] since this works fine. I created this issue, because I wanted to use get with a default parameter and the workaround is way more ugly with if tmp == null.

Reply all
Reply to author
Forward
0 new messages