user1878934
user1878934

Reputation:

Bitbucket webhook to Jenkins

I want to configure Jenkins build on every commit to specific branch. I am trying to use Bitbucket Webhook to Jenkins but it is not working as per expectations. To run it successfully I need to select following two options in Jenkins job 1.Build when a change is pushed to BitBucket and 2. Poll SCM(keeping it blank)

and in webhook as below screenshot

enter image description here

When I untick Omit Branch Name it gives following error.

enter image description here

When I mention branch name to build from in Advance Configurations to Build Options : as below enter image description here

it give following error in logs and do not trigger any build in Jenkins.

2017-07-28 19:18:49,382 ERROR [AtlassianEvent::thread-3] XXXXXXX @4NXRG4x1158x165x0 s2l8ua 10.229.17.70 "PUT /rest/api/latest/projects/STCPLAY/repos/mavensample/browse/pom.xml HTTP/1.1" c.a.s.i.e.AsyncBatchingInvokersTransformer There was an exception thrown trying to dispatch event 'com.atlassian.bitbucket.event.content.FileEditedEvent[source=com.atlassian.stash.internal.content.DefaultContentService@72ae21ba]' for the invoker 'SingleParameterMethodListenerInvoker{method=public void com.nerdwin15.stash.webhook.RepositoryChangeListener.onRefsChangedEvent(com.atlassian.bitbucket.event.repository.RepositoryRefsChangedEvent), listener=com.nerdwin15.stash.webhook.RepositoryChangeListener@356e810b}'
java.lang.RuntimeException: com.atlassian.bitbucket.repository.RefChange.getRefId()Ljava/lang/String;. Listener: com.nerdwin15.stash.webhook.RepositoryChangeListener event: com.atlassian.bitbucket.event.content.FileEditedEvent
    at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:55)
    at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(AsyncBatchingInvokersTransformer.java:109)
    at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1$1.run(AsynchronousAbleEventDispatcher.java:38)
    at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:34)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    ... 1 frame trimmed

Anyone faced this issue and fixed it ? Or there is any other better way to trigger builds on commits pushed to bitbucket on specific branch.

Upvotes: 2

Views: 2308

Answers (1)

Amit
Amit

Reputation: 1006

A couple of suggestions:

  1. You may need to ensure that the branch spec on the Jenkins job (Branches to build) matches the branches that you specify in Branch Options in the BitBucket plugin configuration.
  2. As far as I know, the Build when a change is pushed to BitBucket option is irrelevant in this case.

You can find more detailed instructions here - https://support.cloudbees.com/hc/en-us/articles/226568007-How-to-Trigger-Non-Multibranch-Jobs-from-BitBucket-Server-

Upvotes: -1

Related Questions