jenkinsci / templating-engine-plugin

create tool-agnostic, templated pipelines to be shared by multiple teams
https://jenkinsci.github.io/templating-engine-plugin/latest/
Apache License 2.0
170 stars 59 forks source link

[Bug]: short_name property isn't set on application environment #306

Closed asknet closed 2 years ago

asknet commented 2 years ago

Jenkins Version

2.332.1

JTE Version

2.5.2

Bug Description

In template file, if I access pipelineConfig.application_environments["$appname"] then short_name property isn't set, whereas if I refer environment name directly then short_name property is set. Not sure why there is a difference

Relevant log output

No response

Steps to Reproduce

In template file, if I access pipelineConfig.application_environments["$appname"] then short_name property isn't set, whereas if I refer environment name directly then short_name property is set. Not sure why there is a difference

steven-terrana commented 2 years ago

hey @asknet,

The pipelineConfig variable represents the Aggregated Pipeline Configuration - which means that it's only going to contain the values set via the Pipeline Configuration.

the short_name and long_name properties on Application Environments are on the objects themselves.

So, I would recommend using the Primitive Namespace variable (jte) variable instead of the Aggregated Pipeline Config (pipelineConfig) variable.

Switching to the following will resolve your issue:

jte.application_environments["$appname").short_name