• Icon: Suggestion Suggestion
    • Resolution: Answered
    • None
    • REST API
    • None
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      Its possible to set Global Variables through the REST API, and to set Plan Variables when executing a build but I can't find a way to permanently set a Plan Variable.

      Rationale is I can create branch plan's, set to my VCS branch through REST API, I can enable, favourite and add labels, but the most important part is to set the Plan Variables which override the parent (or global) variables for this branch.

      Referencing https://answers.atlassian.com/questions/35774012/how-to-update-plan-or-global-variable-using-rest-api and https://jira.atlassian.com/browse/BAM-9344 but can't see if this is or isnt a dark feature?

      If it is - can I have an example of POST setting a planvariable?

      If it isn't - can this be added asap to make the REST API useful for creation of plan branches?

          Form Name

            [BAM-18266] Set Plan Variables through REST API

            Rob Fagen added a comment -

            Any thoughts on how this might interact with Plan variables that are secrets (and so encrypted in the DB with a leading "BAMSCRT..." ? Likewise, how would you manage a Spec where you wanted to embed the secret in the plan? Is there an API for creating a BAMSCRT value?

            Rob Fagen added a comment - Any thoughts on how this might interact with Plan variables that are secrets (and so encrypted in the DB with a leading "BAMSCRT..." ? Likewise, how would you manage a Spec where you wanted to embed the secret in the plan? Is there an API for creating a BAMSCRT value?

            sscaff1 please use VariableConfigurationService.createPlanVariable

                /**
                 * Creates new Plan variable.
                 * @param plan plan the variable belongs to
                 * @param variableKey variable key.
                 * @param variableValue variable value
                 * @return created {@link VariableDefinition}
                 * @throws IllegalArgumentException iff variable key is not unique
                 */
                @NotNull
                VariableDefinition createPlanVariable(@NotNull Plan plan, @NotNull String variableKey, @NotNull String variableValue);
            

            Krystian Brazulewicz added a comment - sscaff1 please use VariableConfigurationService.createPlanVariable /** * Creates new Plan variable. * @param plan plan the variable belongs to * @param variableKey variable key. * @param variableValue variable value * @ return created {@link VariableDefinition} * @ throws IllegalArgumentException iff variable key is not unique */ @NotNull VariableDefinition createPlanVariable(@NotNull Plan plan, @NotNull String variableKey, @NotNull String variableValue);

            kbrazulewicz I'm trying to expose a REST endpoint for modifying Plan variables. I've looked through the Atlassian docs here https://docs.atlassian.com/atlassian-bamboo/6.4.1/. I don't see what classes/services I should be using to do this. My initial stab was at com.atlassian.bamboo.variable.VariableConfigurationService. There is a method called setPlanVariables which seems to be what I want. However, I'm not sure how VariableProperties are defined, and I can't find documentation for it in the docs linked. Any help is appreciated.

            Steven Scaffidi added a comment - kbrazulewicz  I'm trying to expose a REST endpoint for modifying Plan variables. I've looked through the Atlassian docs here https://docs.atlassian.com/atlassian-bamboo/6.4.1/.  I don't see what classes/services I should be using to do this. My initial stab was at com.atlassian.bamboo.variable.VariableConfigurationService. There is a method called setPlanVariables which seems to be what I want. However, I'm not sure how VariableProperties are defined, and I can't find documentation for it in the docs linked. Any help is appreciated.

            Since v6.3 bamboo has also supported multiple plan repositories. Is it possible to use the API to update the Plan repository branches, since you can't update Plan variables via the API?

            ClearlyRated added a comment - Since v6.3 bamboo has also supported multiple plan repositories. Is it possible to use the API to update the Plan repository branches, since you can't update Plan variables via the API?

            davidholsgrove most recent Bamboo version (starting from 6.0) added support for Configuration as Code principle (https://confluence.atlassian.com/bamboo/bamboo-specs-894743906.html). The recommended way to manage plan variables is to update them through your own Specs (either Java- or YAML-based).
            If this solution is not applicable to your case then I suggest creating a Bamboo plugin which will expose a REST endpoint for modifying Plan variables.

            Krystian Brazulewicz added a comment - davidholsgrove most recent Bamboo version (starting from 6.0) added support for Configuration as Code principle ( https://confluence.atlassian.com/bamboo/bamboo-specs-894743906.html ). The recommended way to manage plan variables is to update them through your own Specs (either Java- or YAML-based). If this solution is not applicable to your case then I suggest creating a Bamboo plugin which will expose a REST endpoint for modifying Plan variables.

            jmo added a comment -

            I see there is a dark feature flag to enable this for global variables in Bamboo 5.9+: https://jira.atlassian.com/browse/BAM-9344?focusedCommentId=862591&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-862591

            However later in that comment thread it is mentioned it is only for global variables, not plan variables. Is that still true as of Bamboo 6.2.2 or is there a different dark feature flag?

            jmo added a comment - I see there is a dark feature flag to enable this for global variables in Bamboo 5.9+: https://jira.atlassian.com/browse/BAM-9344?focusedCommentId=862591&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-862591 However later in that comment thread it is mentioned it is only for global variables, not plan variables. Is that still true as of Bamboo 6.2.2 or is there a different dark feature flag?

            jmo added a comment -

            Currently we use Python Fabric to issue direct SQL queries against the Bamboo database to update plan variables, then have to restart Bamboo to activate the changes. Apparently Bamboo does not read vars directly from the db upon use, maybe it is keeping them some kind of memory cache that is not updated when the underlying db columns are updated?

            So this would be a huge help to us, I hate having to run raw queries directly against the Bamboo db.

            jmo added a comment - Currently we use Python Fabric to issue direct SQL queries against the Bamboo database to update plan variables, then have to restart Bamboo to activate the changes. Apparently Bamboo does not read vars directly from the db upon use, maybe it is keeping them some kind of memory cache that is not updated when the underlying db columns are updated? So this would be a huge help to us, I hate having to run raw queries directly against the Bamboo db.

              Unassigned Unassigned
              8d52fd7dd939 David Holsgrove
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: