@@ -152,6 +152,7 @@ public class GitSCM extends GitSCMBackwardCompatibility {
152152    public  static  final  String  GIT_LOCAL_BRANCH  = "GIT_LOCAL_BRANCH" ;
153153    public  static  final  String  GIT_CHECKOUT_DIR  = "GIT_CHECKOUT_DIR" ;
154154    public  static  final  String  GIT_COMMIT  = "GIT_COMMIT" ;
155+     public  static  final  String  GIT_COMMIT_MESSAGE  = "GIT_COMMIT_MESSAGE" ;
155156    public  static  final  String  GIT_PREVIOUS_COMMIT  = "GIT_PREVIOUS_COMMIT" ;
156157    public  static  final  String  GIT_PREVIOUS_SUCCESSFUL_COMMIT  = "GIT_PREVIOUS_SUCCESSFUL_COMMIT" ;
157158
@@ -1200,7 +1201,9 @@ public void checkout(Run<?, ?> build, Launcher launcher, FilePath workspace, Tas
12001201
12011202        // Needs to be after the checkout so that revToBuild is in the workspace 
12021203        try  {
1203-             printCommitMessageToLog (listener , git , revToBuild );
1204+             String  shortMessage  = getCommitMessage (listener , git , revToBuild );
1205+             listener .getLogger ().println ("Commit message: \" "  + shortMessage  + "\" " );
1206+             environment .put (GIT_COMMIT_MESSAGE , shortMessage );
12041207        } catch  (GitException  ge ) {
12051208            listener .getLogger ().println ("Exception logging commit message for "  + revToBuild  + ": "  + ge .getMessage ());
12061209        }
@@ -1224,16 +1227,30 @@ public void checkout(Run<?, ?> build, Launcher launcher, FilePath workspace, Tas
12241227        }
12251228    }
12261229
1227-     private  void  printCommitMessageToLog (TaskListener  listener , GitClient  git , final  Build  revToBuild )
1228-             throws  IOException  {
1230+     /** 
1231+      *  Get the short message from the last commit 
1232+      * 
1233+      * @param listener 
1234+      *      Used for writing to build console 
1235+      * @param git 
1236+      *      Used for invoking Git 
1237+      * @param revToBuild 
1238+      *      Points to the revision we'll be building. This includes all the branches we've merged. 
1239+      * 
1240+      * @return Short message for the commit 
1241+      * @throws IOException 
1242+      */ 
1243+     private  String  getCommitMessage (TaskListener  listener , GitClient  git , final  Build  revToBuild ) throws  IOException  {
12291244        try  {
12301245            RevCommit  commit  = git .withRepository (new  RevCommitRepositoryCallback (revToBuild ));
1231-             listener . getLogger (). println ( "Commit message:  \" "  +  commit .getShortMessage () +  " \" " 
1246+             return   commit .getShortMessage ();
12321247        } catch  (InterruptedException  | MissingObjectException  e ) {
12331248            e .printStackTrace (listener .error ("Unable to retrieve commit message" ));
12341249        }
1250+         return  "" ;
12351251    }
12361252
1253+ 
12371254    /** 
12381255     * Build up change log from all the branches that we've merged into {@code revToBuild}. 
12391256     * 
0 commit comments