SVNÌá½»ºó×Ô¶¯ÍÆËÍÏûÏ¢µ½¶¤¶¤Èº
¶¤¶¤ÉèÖûúÆ÷ÈËÅäÖà 1¡¢½øÈëÅäÖûúÆ÷ÈËÈë¿Ú
2¡¢Ìí¼Ó»úÆ÷ÈË3¡¢²âÊÔWebHookÇëÇó
±¾ÈËʹÓÃPostman½øÐвâÊÔ
4¡¢ÅäÖÃSVN
4.1 ÅäÖÃ Pre-commit hook
ÅäÖòÎÊý
@echo off setlocal set REPOS=%1 set TXN=%2 rem check that logmessage contains at least 10 characters svnlook log %REPOS% -t %TXN% | findstr "....." > nul if %errorlevel% gtr 0 goto err exit 0 :err echo ÉÏ´«Ê§°Ü£¡ÇëÌí¼Ó×¢ÊÍ. ×¢Êͳ¤¶ÈÖÁÉÙΪ5¸ö×Ö·û. Commit aborted! 1>&2 exit 1ÓÉÓÚ¶¤¶¤ÌṩµÄ½Ó¿ÚÊÇhttpsÐÒ飬curlÐèÒªÖ§³Öhttps£¬Òò´Ëͨ¹ýjava´úÂë·¢ÆðPostÇëÇ󣬴ò°ü³É¿ÉÔËÐеÄjar£¬È»ºóÓÃpost-commit hookµ÷Ó㬴«ÈëÐÅÏ¢¼´¿É¡£
package com.wolf.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; import javax.net.ssl.HttpsURLConnection; public class Request { public static void main(String[] args) throws Exception { String token = args[0]; String content = args[1]; content = "{\"msgtype\": \"text\",\"text\": {\"content\": \""+content+"\"}}"; httpsRequest("https://oapi.dingtalk.com/robot/send?access_token="+token, "POST", content); System.out.println("OK"); System.exit(0); } /** * ·¢ËÍhttpsÇëÇó */ public static String httpsRequest(String requestUrl, String requestMethod, String outputStr) throws Exception { HttpsURLConnection conn = null; BufferedReader bufferedReader = null; try { URL url = new URL(requestUrl); conn = (HttpsURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setUseCaches(false); conn.setRequestMethod(requestMethod); conn.setRequestProperty("content-type", "application/json"); if (null != outputStr) { OutputStream outputStream = conn.getOutputStream(); outputStream.write(outputStr.getBytes("utf-8")); outputStream.close(); } bufferedReader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); String str = null; StringBuffer buffer = new StringBuffer(); while ((str = bufferedReader.readLine()) != null) { buffer.append(str); } return buffer.toString(); } catch (Exception e) { throw e; } finally { if (conn != null) { conn.disconnect(); } if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { } } } } }½á¹ûÈçÏ£º
posted @
¡¡