Sunday, July 31, 2016

Bamboo DSL - Build DSL & Code together

How to check groovy binding contents in you DSL

Simple code snippet to be added to the groovy script:

    if (it.key.toString().toLowerCase().matches("password"))
        logger.addBuildLogEntry ( "Key: " + it.key + " value ***********"  )
    } else
        logger.addBuildLogEntry ( "Key: " + it.key + " value " + it.value )

Sample output:

simple 31-Jul-2016 13:09:10 DSL Pre Build Processing starting... 
simple 31-Jul-2016 13:09:10    on DESKTOP-6QJ44JS
simple 31-Jul-2016 13:09:11 Key: logger value
simple 31-Jul-2016 13:09:11 Key: dslHelper value org.valens.utils.DslHelper@32ee93bb
simple 31-Jul-2016 13:09:11 Key: planManager value com.atlassian.bamboo.plan.PlanManagerImpl@6c647f5
simple 31-Jul-2016 13:09:11 Key: environmentService value com.atlassian.bamboo.deployments.environments.service.EnvironmentServiceImpl@4a39933
simple 31-Jul-2016 13:09:11 Key: buildContext value
simple 31-Jul-2016 13:09:11 Key: SDKPATH value C:\Atlassian\atlassian-plugin-sdk-6.2.9\bin
simple 31-Jul-2016 13:09:11 Key: bambooDelimiterParsingDisabled_0 value true
simple 31-Jul-2016 13:09:11 Key: filter_pattern_option_0 value none
simple 31-Jul-2016 13:09:11 Key: filter_pattern_regex_0 value 
simple 31-Jul-2016 13:09:11 Key: changeset_filter_pattern_regex_0 value 
simple 31-Jul-2016 13:09:11 Key: repository_common_quietPeriod_enabled_0 value false
simple 31-Jul-2016 13:09:11 Key: repository_common_quietPeriod_period_0 value 10
simple 31-Jul-2016 13:09:11 Key: repository_common_quietPeriod_maxRetries_0 value 5
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_repository_0 value iuliushutuleac/bamboo-ansible-tasks
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_scm_0 value GIT
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_branch_0 value master
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_showAdvancedOptions_0 value false
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_commandTimeout_0 value 180
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_verbose_logs_0 value false
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_fetch_whole_repository_0 value false
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_git_useShallowClones_0 value false
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_git_useSubmodules_0 value false
simple 31-Jul-2016 13:09:11 Key: repository_bitbucket_git_useRemoteAgentCache_0 value false

Tuesday, July 26, 2016

Build templating - getting started - the quick guide

To get started there are 2 steps to be performed:

  • pick a plan which you would like to be a template, tick the "Is Template" flag. This will allow the plan to appear in the other plans in the dropdown with template names.
  • Once you have the Template allowed, go in the configuration of the other plan - Miscellaneous page.
    Here you should find a section "Template list" with a dropdown. Select from the dropdown the template name and tick what would you like to be templated.
The replication can be started in few modes (result is same but depending on your permissions in Bamboo one can be more comfortable than the other):
  • by doing changes to the template (save on Miscellaneous page)
  • by going to the template operations menu
  • from System administration / Addons / replication operations
As a test I would suggest to trigger the replication without any server pause. If you wait a bit you should see the progress in the replication operations.
One important aspect, name your tasks ! In order for templating to work properly please make sure you give your tasks unique names, this will ensure the engine can identify which task from template has been copied over and also will ensure the state of the tasks is maintained between copies.
Another important aspect, replication is not done on the fly, it needs to be triggered,

Monday, July 18, 2016

Task templating process - advanced topics

 Due to the complexity of the repository definitions in Bamboo I have implemented pretty much 2 models for merging:

- without task reordering - quite simple case, the merging is split in 2 phases: remove almost all tasks from the build configuration, keep checkout tasks, and second phase bring all other tasks from the template. This method works fine on simple jobs, when you have to template jobs that checkout code at the start of jobs.

- with task reordering - in this case the current tasks are backed up, everything is pulled from template and if the engine is finding a checkout task it will try to find its configuration in the backup.

In terms of timeline the first method was the original merging solution, the second solution was only recently implemented. In order to switch between merge engines you need to tick the "Attempt to maintain task order" checkbox under configuration.

Saturday, July 9, 2016

Bamboo Templated plans get Deployment support, simple variables control templating this time.

New features that will help you keep an eye on your templating:

- reports regarding which templates are used
- live log review for replication progress
- trigger replication from main menu
- secure replication menu from administration page
Bamboo Dynamic Plans becomes Dynamic and DSL ! Many new features and a powerful groovy based DSL !