diff options
-rw-r--r-- | src/main/java/uk/co/blatech/blaears/controllers/GitRelayController.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/uk/co/blatech/blaears/controllers/GitRelayController.java b/src/main/java/uk/co/blatech/blaears/controllers/GitRelayController.java index f5d240e..4727c59 100644 --- a/src/main/java/uk/co/blatech/blaears/controllers/GitRelayController.java +++ b/src/main/java/uk/co/blatech/blaears/controllers/GitRelayController.java @@ -1,11 +1,13 @@ package uk.co.blatech.blaears.controllers; +import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; +import uk.co.blatech.blaears.models.gitlab.Commit; import uk.co.blatech.blaears.models.gitlab.Push; import java.io.IOException; @@ -20,8 +22,15 @@ public class GitRelayController { @RequestMapping(value = "/gitlab", method = RequestMethod.POST) String relay(@RequestBody Push pushMsg, Model model){ try { + String commitMsg = ""; + for (Commit commit: pushMsg.getCommits()) { + if (StringUtils.isNotEmpty(commitMsg)) { + commitMsg += ", "; + } + commitMsg += "\"" + commit.getMessage() + "\""; + } //DANGER - Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "echo theblueroom " + pushMsg.getUserName() + " pushed to " + pushMsg.getRepository().getName() + " | bash /home/smsd/msgrelay.bash "}); + Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "echo theblueroom " + pushMsg.getUserName() + " pushed to " + pushMsg.getRepository().getName() + ": "+ commitMsg + " | bash /home/smsd/msgrelay.bash "}); model.addAttribute("result", "OK"); } catch (IOException e) { System.out.println("Failed to run command"); |