Gocd: Templated pipelines misleadingly can't shadow template environment variables

Created on 26 Feb 2016  路  7Comments  路  Source: gocd/gocd

Issue Type

Bug Report

Summary

Given a template that defines an environment variable and a pipeline defined in terms of that template, the UI presents the opportunity to define environment variables, providing the illusion that these more locally specified values will shadow those in the template. However this is not the case.

Environment
Basic environment details

Go Version: 15.2.0(2248-c1f90a6aa3192a)

JAVA Version: Oracle JDK 1.8.0_66-b17

OS: Linux, amd64, 3.2.0-88-virtual, 4, 0.34

Additional Environment Details

none

Steps to Reproduce

1) Given the following config xml (please excuse any errors, as it was hand-craft to anonymise it):

<?xml version="1.0" encoding="utf-8"?>
<cruise xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="cruise-config.xsd" schemaVersion="75">
  <pipelines group="g">
    <pipeline name="x" labeltemplate="${COUNT}" template="t">
      <environmentvariables>
        <variable name="FOO">
          <value>B</value>
        </variable>
      </environmentvariables>
      <materials>
        <git url="[email protected]:x/x.git">
        </git>
      </materials>
    </pipeline>
  </pipelines>
  <templates>
    <pipeline name="t">
      <stage name="s" cleanWorkingDir="true">
        <environmentvariables>
          <variable name="FOO">
            <value>A</value>
          </variable>
        </environmentvariables>
        <jobs>
          <job name="j">
            <tasks>
              <exec command="/bin/bash">
                <arg>-c</arg>
                <arg>x</arg>
                <runif status="passed" />
              </exec>
            </tasks>
          </job>
        </jobs>
      </stage>
    </pipeline>
  </templates>
</cruise>

2) Run pipeline x

Expected Results

It is expected that the more locally-scope defined FOO be equal to B.

Actual Results

FOO is still set to A.

Log snippets

none

Code snippets/Screenshots

none

Any other info

none

stale

Most helpful comment

Is there any update on this issue? Or is there any workaround?

All 7 comments

This is a big issue for us as well. I would really like to set defaults in a template but be able to override them from the pipeline using the template.

The only way to set defaults now is to create an environment with said environment variables and then override them in the pipeline. However an environment requires to have specific agents assigned, whereas I want to use the full pool of agents for deployments.

The ability to set environment variables at template level - not stage or job - and let it have lower specificity than the pipeline using the template would actually solve this.

Next to that it would help to show the environment variables that are obfuscated in all environment variable edit screens. And the key values set at a higher level. That makes it much easier to override a default.

Is there any update on this issue? Or is there any workaround?

I no longer use GoCD, so I don't even know if this is still an issue.

I can confirm this is still an issue! @dwijnand can you reopen this? I don't know any admins I can ping here to do that.

BTW, our environment is:
Basic environment details
Go Version: 18.2.0 (6000-9f5da26a5c6c8b294f26fdec8b618a8f2edb47ce)
JAVA Version: 1.8.0_131
OS: Linux 4.4.111+
Database schema version: 1801007

Same issue here, using version 18.3.0, an environment variable defined in a template can not be overridden by the pipelines that uses this template

This issue has been automatically marked as stale because it has not had activity in the last 90 days.
If you can still reproduce this error on the master branch using local development environment or on the latest GoCD Release, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

Was this page helpful?
0 / 5 - 0 ratings