Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-11257

Conditional build step depending on value (or existence) of variable

    • 46
    • 13
    • 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.

      Allow an option so that a build step is conditional on the presence or value of a variable.

      A good use case is given here https://answers.atlassian.com/questions/36658/is-it-possible-to-tag-a-bamboo-build-only-if-a-particular-variable-is-set

      A variant of this use case would be to run the VCS tagging step only if the ${bamboo.jira.version} was set - i.e. tag if the build was initiated from jira as a release, but not if the build was initiated manually or due to a repository update.

      Atlassian Update

      We have an App that allows this functionality, which can be downloaded from the Atlassian Marketplace here: Conditional tasks for Bamboo. The App is compatible with Bamboo versions 6.7.1 and above. Please check out the App, and let us know how it works for you!

            [BAM-11257] Conditional build step depending on value (or existence) of variable

            rogierhelmer if you want to configure your task to be executed depending on runtime variables value - yes. See example with Export to Java Specs action at plan config actions

            if you want Java specs code to be processed depending on runtime variables - then it's not possible

            Alexey Chystoprudov added a comment - rogierhelmer if you want to configure your task to be executed depending on runtime variables value - yes. See example with Export to Java Specs action at plan config actions if you want Java specs code to be processed depending on runtime variables - then it's not possible

            Rogier_H added a comment -

            Can this plugin also be used with the java specs?

            Rogier_H added a comment - Can this plugin also be used with the java specs?

            Michael J. Tichy added a comment - - edited

            @280c4e01fe54    That can be done by having a "Inject Bamboo variables" task prior to your conditional task.  Info regarding that type of task can be found here:  Configuring a variables task

            Michael J. Tichy added a comment - - edited @ 280c4e01fe54     That can be done by having a "Inject Bamboo variables" task prior to your conditional task.  Info regarding that type of task can be found here:   Configuring a variables task

            Please add this feature.

            schow-lmi3d added a comment - Please add this feature.

            Michael J. Tichy added a comment - - edited

            Having issues matching this string:

            WEBAPI - TEMPLATE_WEBAPI - features-ALPHA-917-NETCoreMigration-MJTICH 5

            using the expression:

            features-.|DEV-.|QA-.*

            log file shows:

            Skipping task because conditions were not met.

            I have validated the expression against the string via https://regexr.com/

            Is there some part of matching using regular expression that I'm not aware of?  Any information is appreciated.

             

            Michael J. Tichy added a comment - - edited Having issues matching this string: WEBAPI - TEMPLATE_WEBAPI - features-ALPHA-917-NETCoreMigration-MJTICH 5 using the expression: features-. |DEV-. |QA-.* log file shows: Skipping task because conditions were not met. I have validated the expression against the string via  https://regexr.com/ Is there some part of matching using regular expression that I'm not aware of?  Any information is appreciated.  

            ieng.lao try to use variable without bamboo. prefix, e.g. DEPLOYMENT or inject.BAMBOO_DEP_STATUS

            Alexey Chystoprudov added a comment - ieng.lao try to use variable without bamboo. prefix, e.g. DEPLOYMENT or inject.BAMBOO_DEP_STATUS

            Ieng Lao added a comment -

            Hi.

            I am not able to get this plugin to work. Just for testing, I have defined a variable (DEPLOYMENT=true) in the plan. On the Conditional task (Variable), I entered "bamboo.DEPLOYMENT" and selected "exists". 

            Control new release creation from Bamboo variables

            Execution Condition
            Entered "bamboo.DEPLOYMENT" 
             
            I ran the plan and got this error message "Condition com.atlassian.bamboo.plugins.bamboo-conditional-tasks:variableCondition wasn't met. Skipping task." 
             
            I also tried to use Injected variable with various ways for the conditional task but not help. The following ways I tried:
            ${bamboo.inject.BAMBOO_DEPLOYMENT}, ${inject.BAMBOO_DEPLOYMENT}, or .inject.BAMBOO_DEPLOYMENT. 
             
            Starting task 'Inject Bamboo variables' of type 'com.atlassian.bamboo.plugins.bamboo-variable-inject-plugin:inject'
            Injected variable bamboo.inject.BAMBOO_DEP_STATUS=false in RESULT scope
            Injected variable bamboo.inject.BAMBOO_DEPLOYMENT=true in RESULT scope
             
            I could not find any documentation on this. Any help will be greatly appreciated.
             
             
            Regards,
             
            Ieng Lao
             
             

            Ieng Lao added a comment - Hi. I am not able to get this plugin to work. Just for testing, I have defined a variable (DEPLOYMENT=true) in the plan. On the Conditional task (Variable), I entered "bamboo.DEPLOYMENT" and selected "exists".  Control new release creation from Bamboo variables Execution Condition Entered "bamboo.DEPLOYMENT"    I ran the plan and got this error message "Condition com.atlassian.bamboo.plugins.bamboo-conditional-tasks:variableCondition wasn't met. Skipping task."    I also tried to use Injected variable with various ways for the conditional task but not help. The following ways I tried: ${bamboo.inject.BAMBOO_DEPLOYMENT}, ${inject.BAMBOO_DEPLOYMENT}, or .inject.BAMBOO_DEPLOYMENT.    Starting task 'Inject Bamboo variables' of type 'com.atlassian.bamboo.plugins.bamboo-variable-inject-plugin:inject' Injected variable bamboo.inject.BAMBOO_DEP_STATUS=false in RESULT scope Injected variable bamboo.inject.BAMBOO_DEPLOYMENT=true in RESULT scope   I could not find any documentation on this. Any help will be greatly appreciated.     Regards,   Ieng Lao    

            Atlassian Update

            Hi everyone,

            Thanks for your interest in this issue.
            This request is considered a potential addition to our longer-term roadmap.

            We'll typically review this request in about 6 months time, at which point we’ll consider whether we need to alter its status.

            For the nearest future we've decided to prioritise other areas of the Bamboo roadmap, including:

            1. Robustness of Plan Branches
            2. Performance and stability improvements
            3. Providing building blocks for High Availability and Disaster Recovery solutions
            4. Improving permission system
            5. Allowing per-project allocation of resources
            6. Improving Bitbucket Server and Jira integrations

            You can learn more about our approach to highly voted server suggestions here.

            To learn more on how your suggestions are reviewed, see our updated workflow for server feature suggestions.

            Kind regards,
            Bamboo Team

            Martyna Wojtas (Inactive) added a comment - Atlassian Update Hi everyone, Thanks for your interest in this issue. This request is considered a potential addition to our longer-term roadmap. We'll typically review this request in about 6 months time, at which point we’ll consider whether we need to alter its status. For the nearest future we've decided to prioritise other areas of the Bamboo roadmap, including: Robustness of Plan Branches Performance and stability improvements Providing building blocks for High Availability and Disaster Recovery solutions Improving permission system Allowing per-project allocation of resources Improving Bitbucket Server and Jira integrations You can learn more about our approach to highly voted server suggestions here . To learn more on how your suggestions are reviewed, see our updated workflow for server feature suggestions . Kind regards, Bamboo Team

            mark.gillespie1, version v0.7 of plugin released at Marketplace with fix of #2. Please let me know if it solves the issue. 

            Alexey Chystoprudov added a comment - mark.gillespie1 , version v0.7 of plugin released at Marketplace with fix of #2 . Please let me know if it solves the issue. 

            Hmm, images don't work:

            (Condition type)

            Variable

            inject.branchName equals develop

            markgillespien added a comment - Hmm, images don't work: (Condition type) Variable inject.branchName equals develop

              achystoprudov Alexey Chystoprudov
              3d0b503a55e3 Matthew J. Dovey
              Votes:
              530 Vote for this issue
              Watchers:
              252 Start watching this issue

                Created:
                Updated:
                Resolved: