gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/gerritnotifier/ParameterExpander.java
/**
     * Expands all types of parameters in the string and returns the "replaced" string.
     * Both types means both $ENV_VARS and &lt;PLUGIN_VARS&gt;
     * @param gerritCommand the command "template"
     * @param r the build containing the environment vars.
     * @param taskListener the taskListener
     * @param parameters the &lt;parameters&gt; from the trigger.
     * @return the expanded string.
     */
Expands all types of parameters in the string and returns the "replaced" string.
Both types means both $ENV_VARS and <PLUGIN_VARS>
@param gerritCommand the command "template"
@param r the build containing the environment vars.
@param taskListener the taskListener
@param parameters the <parameters> from the trigger.
@return the expanded string.
Expands all types of parameters in the string and returns the " replaced " string . Both types means both $ENV_VARS and <PLUGIN_VARS > @param gerritCommand the command " template " @param r the build containing the environment vars . @param taskListener the taskListener @param parameters the <parameters > from the trigger . @return the expanded string .
private String expandParameters(String gerritCommand, AbstractBuild r, TaskListener taskListener,
            Map<String, String> parameters) {
        if (r != null && taskListener != null) {
            try {
                gerritCommand = r.getEnvironment(taskListener).expand(gerritCommand);
            } catch (Exception ex) {
                logger.error("Failed to expand env vars into gerrit cmd. Gerrit won't be notified!!", ex);
                return null;
            }
        }
        for (Map.Entry<String, String> param : parameters.entrySet()) {
            gerritCommand = gerritCommand.replace("<" + param.getKey() + ">", param.getValue());
        }
        return gerritCommand;
    }
private String expandParameters ( String gerritCommand , AbstractBuild r , TaskListener taskListener , Map < String , String > parameters ) { if ( r != null && taskListener != null ) { try { gerritCommand = r . getEnvironment ( taskListener ) . expand ( gerritCommand ) ; } catch ( Exception ex ) { logger . error ( "Failed to expand env vars into gerrit cmd. Gerrit won't be notified!!" , ex ) ; return null ; } } for ( Map . Entry < String , String > param : parameters . entrySet ( ) ) { gerritCommand = gerritCommand . replace ( "<" + param . getKey ( ) + ">" , param . getValue ( ) ) ; } return gerritCommand ; }
Expands all types of parameters in the string and returns the "replaced" string.
Expands all types of parameters in the string and returns the " replaced " string .