Allow conditional task to use environment variables

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: Tasks
    • None
    • 0
    • 1

      Problem Definition

      Currently, Conditional Tasks in Bamboo only support the use of build plan variables. However, there are many other environment variables available in the context, and these cannot be utilized at this time.
       
      For example, if a customer wants to execute a script task based on the agent's operating system, they would use the environment variable WRAPPER_OS. However, this variable cannot currently be used in a conditional task.

      Suggested Solution

      This can be accomplished in several ways. Depending on compatibility, one of the following solutions can be considered.

      1. Enable the conditional task to support the use environment variables
      2. Enable the conditional task to support the use of agent capabilities
      3. Add a new task to inject all the environment variables as build plan variables.

      Workaround

      • Create a plan with below tasks:
        • Create a script task to write the environment variable to a flat file in a key value pair format.
        • Use Inject variable task to add the build variable during the run time using the flat file created in above step
      • Below is the sample tasks configuration
          - script:
              interpreter: SHELL
              scripts:
              - |-
                echo "WRAPPER_OS="$WRAPPER_OS > inject.properties
                cat inject.properties
          - inject-variables:
              file: inject.properties
              scope: LOCAL
              namespace: inject
          - script:
              interpreter: SHELL
              scripts:
              - echo "hello linux"
              conditions:
              - variable:
                  equals:
                    bamboo.inject.WRAPPER_OS: linux
        

              Assignee:
              Unassigned
              Reporter:
              Venkata Sateesh Pentela
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: