webhooks의 content type이 application/json인 경우, jenkins에서 hook 결과가 아래 IllegalArgumentException이 발생되어 삽질을 할 수 있다. 


Caused by: java.lang.IllegalArgumentException: Not intended to be browsed interactively (must specify payload parameter)

at com.cloudbees.jenkins.GitHubWebHook.doIndex(GitHubWebHook.java:154)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:601)

at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:298)

at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:161)

at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:96)

at org.kohsuke.stapler.MetaClass$2.dispatch(MetaClass.java:164)

at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:733)




관련 내용을 살펴보기 위해 검색했다.


http://developer.cloudbees.com/bin/view/DEV/GitHub+Commit+Hooks+HOWTO

http://stackoverflow.com/questions/15429448/how-to-configure-cloudbees-jenkins-to-trigger-build-on-push-to-github

http://ics-software-engineering.github.io/play-example-continuous-integration/


관련해서 특별한 문제점을 찾을 수 없었다. 



참고로 GitHubWebHook plugin 소스를 확인해보니. payload 정보를 읽지 못한 부분이었다. 


 public void doIndex(StaplerRequest req) {

151

152         String eventType = req.getHeader("X-GitHub-Event");

153         if ("push".equals(eventType)) {

154             String payload = req.getParameter("payload");

155             if (payload == null) {

156                 throw new IllegalArgumentException("Not intended to be browsed interactively (must specify payload parameter). " +

157                         "Make sure payload version is 'application/vnd.github+form'.");

158             }

159             processGitHubPayload(payload,GitHubPushTrigger.class);

160         } else if (eventType != null && !eventType.isEmpty()) {

161             throw new IllegalArgumentException("Github Webhook event of type " + eventType + " is not supported. " +

162                     "Only push events are current supported");

163         } else {

164             //Support github services that don't specify a header.

165             //Github webhook specifies a "X-Github-Event" header but services do not.

166             String payload = req.getParameter("payload");

167             if (payload == null) {

168                 throw new IllegalArgumentException("Not intended to be browsed interactively (must specify payload parameter)");

169             }

170             processGitHubPayload(payload,GitHubPushTrigger.class);

171         }




결론은 특수 문자 및 한글 이슈로 인해서 application/json이 동작이 안될 수 있다.  

Webhooks/Manage webhook의 Content type에 application/x-www-form-urlencoded 를 설정하고 webhook 테스트를 진행해보니. 잘 동작되었다.

Posted by '김용환'
,