Sunday, July 31, 2016

How to check groovy binding contents in you DSL

Simple code snippet to be added to the groovy script:

binding.variables.each{
    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 com.atlassian.bamboo.build.logger.BuildLoggerImpl@1102b86c
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 com.atlassian.bamboo.v2.build.BuildContextImpl@b1f71b01
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

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete