Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added macros provided by this plugin

...

Code Block
java
java
@Extension
public class GitRevisionTokenMacro extends DataBoundTokenMacro {
    /** Number of chars to use */
    @Parameter
    public int length = 40;

    @Override
    public boolean acceptsMacroName(String macroName) {
        return macroName.equals("GIT_REVISION");
    }

    @Override
    public String evaluate(AbstractBuild<?, ?> context, TaskListener listener, String macroName)
            throws MacroEvaluationException, IOException, InterruptedException {
        BuildData data = context.getAction(BuildData.class);
        if (data == null) {
            return "";  // shall we report an error more explicitly?
        }

        Revision lb = data.getLastBuiltRevision();
        if (lb == null) {
            return "";
        }

        String s = lb.getSha1String();
        return s.substring(0, Math.min(length, s.length()));
    }
}

Macros provided by this plugin

Code Block
${ENV,var=VARIABLENAME} // returns the number of characters in the result of evaluating MACRO_NAME.
${FILE,path=foo.txt} // returns the content of the specified file.
${????} // returns properties from a property file in the build workspace.
${XML, file="pom.xml", xpath="/project/version/text()"} // returns contents from an XML file.

Token Transforms

There are a few different transforms that can be applied on top of the result of the token itself. These are similar to BASH shell transforms.

...