Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

How the changes of certain branch in bitbucket trigger the quickbuild to run? #4128

CaoFangyuan ·

Hi,

I am new to quickbuild, and I want to do the thinks like this:
We are developing our code with bitbucket and there are many branches, we want to watch a certain branch named "develop", and when find any code changes on this branch, the quickbuild can be triggered automatically to run the step I set.
For now, my setting on quickbuild are:

  1. The schedule is periodical schedule with every 5 minutes.
  2. The build condition is If changes found in referenced repositories.
  3. For Repositories, I select the bitbucket server. Actually I am not clear about the difference between bitbucket server and bitbucket cloud, but I select the server one. And I set the url and username, password. Also, I set the branch name as develop.
    But here is the problem, when I change of code in develop branch and push to the bitbucket, the quickbuild doesn't been triggered automatically.
    Do you know what's wrong here?
  • replies 22
  • views 789
  • stars 1
robinshen ADMIN ·

"BitBucket cloud" is for bitbucket.org, and "BitBucket server" is for self-installed BitBucket. As to changes not triggering build, have you added a step inside master step to checkout from your defined BitBucket repository? Also QB will poll the repository every 5 mins (as defined by the schedule) to determine if a build needs to be triggered.

CaoFangyuan ·

Hi, robin, thanks for your reply.
Yes, there is step under the master step which is to download the code, but it seems doesn't work. My colleague said that our QB is in POC instance, so it can not work in a trigger mode, we need to change to official instance. So I am wondering that's the problem of my setting or need to be official instance?

mbachhav-intel ·

Hi Robin,

We have checkout step under master configuration. However when I run the configuration manually checkout step fails because bitbucket RESTApi returns 404 status. Can you guide on how to solve it?

14:18:39,743 INFO - Checking step execute condition...

14:18:39,744 INFO - Step execute condition satisfied, executing...

14:18:39,874 INFO - Executing pre-execute action...

14:18:39,874 INFO - Running step...

14:18:39,874 INFO - Taking snapshot of repository 'repo'...

14:18:39,874 INFO - Determining head revision for repository: repo

14:18:39,875 DEBUG - sync working directory [C:\Quickbuild2\buildagent\workspace\root\test]...

14:18:39,875 DEBUG - Detect whether repository settings have been changed ...

14:18:39,876 DEBUG - Loading scm rc file ...

14:18:39,876 WARN - Repository RC file C:\Quickbuild2\buildagent\workspace\root\test.qbcache\qb-scm.xml doesn't exist!

14:18:39,877 WARN - Repository setting changed: pushurl: null -> ssh://git@bitbucket-server:7999/mtinb/burn.git
fetchurl: null -> ssh://git@bitbucket-server:7999/mtinb/120s_burn.git
username: null -> lab_mtiregression
, deleting working directory C:\Quickbuild2\buildagent\workspace\root\test

14:18:39,880 DEBUG - Creating git repository to directory [C:\Quickbuild2\buildagent\workspace\root\test] ...

14:18:39,883 DEBUG - Executing command: "C:\Program Files\Git\bin\git.exe" clone --no-checkout ssh://git@bitbucket-server:7999/mtinb/burn.git C:\Quickbuild2\buildagent\workspace\root\test

14:18:39,884 DEBUG - Command working directory: C:\Quickbuild2\buildagent\workspace\root\test

14:18:40,050 ERROR - Cloning into 'C:\Quickbuild2\buildagent\workspace\root\test'...

14:18:46,823 DEBUG - Executing command: "C:\Program Files\Git\bin\git.exe" remote prune origin

14:18:46,823 DEBUG - Command working directory: C:\Quickbuild2\buildagent\workspace\root\test

14:18:47,073 DEBUG - Executing command: "C:\Program Files\Git\bin\git.exe" fetch --all --tags

14:18:47,073 DEBUG - Command working directory: C:\Quickbuild2\buildagent\workspace\root\test

14:18:47,172 DEBUG - Fetching origin

14:18:47,517 DEBUG - Executing command: "C:\Program Files\Git\bin\git.exe" fetch origin bitbucketcheck

14:18:47,517 DEBUG - Command working directory: C:\Quickbuild2\buildagent\workspace\root\test

14:18:47,844 ERROR - From ssh:// :7999/mtinb/burn

14:18:47,844 ERROR - * branch bitbucketcheck -> FETCH_HEAD

14:18:47,881 DEBUG - Saving scm rc file ...

14:18:47,888 DEBUG - Saving scm rc file ...

14:18:47,892 DEBUG - Executing command: "C:\Program Files\Git\bin\git.exe" log -1 --pretty=format:%H FETCH_HEAD --

14:18:47,892 DEBUG - Command working directory: C:\Quickbuild2\buildagent\workspace\root\test

14:18:48,002 DEBUG - 73a64d89d1247d0bf53c2c3ff93d8b70f47f1e50

14:18:48,003 INFO - Checking out revision '73a64d89d1247d0bf53c2c3ff93d8b70f47f1e50' of repository 'repo'...

14:18:48,473 WARN - Repository 'repo' in build '1.0.62' does not have revision set.

14:18:48,473 WARN - Can not calculate change sets as revision of repository 'repo' is not set for base build '1.0.62'.

14:18:48,524 INFO - Executing post-execute action...

14:18:48,525 ERROR - Step 'master>bitbuckeco' is failed.
com.sun.jersey.api.client.UniformInterfaceException: POST https://bitbucket-server/rest/api/1.0/build-status/1.0/commits/73a64d89d1247d0bf53c2c3ff93d8b70f47f1e50 returned a response status of 404
at com.sun.jersey.api.client.WebResource.voidHandle(WebResource.java:582)
at com.sun.jersey.api.client.WebResource.access$500(WebResource.java:69)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:483)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository.updateCommitStatus(BitbucketServerRepository.java:244)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository.onBuildStart(BitbucketServerRepository.java:78)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository.checkoutByRevision(BitbucketServerRepository.java:73)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998.CGLIB$checkoutByRevision$3( )
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998$$FastClassByCGLIB$$6717a6ce.invoke( )
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:261)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998.checkoutByRevision( )
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository.checkoutByRevision(BitbucketServerRepository.java:39)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998.CGLIB$checkoutByRevision$2( )
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998$$FastClassByCGLIB$$6717a6ce.invoke( )
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:261)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998.checkoutByRevision( )
at com.pmease.quickbuild.repositorysupport.Repository.checkout(Repository.java:228)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998.CGLIB$checkout$91( )
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998$$FastClassByCGLIB$$6717a6ce.invoke( )
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:261)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$13018998.checkout( )
at com.pmease.quickbuild.repositorysupport.CheckoutStep.run(CheckoutStep.java:71)
at com.pmease.quickbuild.repositorysupport.CheckoutStep$$EnhancerByCGLIB$$fccbc195.CGLIB$run$0( )
at com.pmease.quickbuild.repositorysupport.CheckoutStep$$EnhancerByCGLIB$$fccbc195$$FastClassByCGLIB$$23a375da.invoke( )
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:261)
at com.pmease.quickbuild.repositorysupport.CheckoutStep$$EnhancerByCGLIB$$fccbc195.run( )
at com.pmease.quickbuild.stepsupport.Step.doExecute(Step.java:664)
at com.pmease.quickbuild.stepsupport.Step.execute(Step.java:570)
at com.pmease.quickbuild.stepsupport.StepExecutionJob.executeStepAwareJob(StepExecutionJob.java:31)
at com.pmease.quickbuild.stepsupport.StepAwareJob.executeBuildAwareJob(StepAwareJob.java:56)
at com.pmease.quickbuild.BuildAwareJob.execute(BuildAwareJob.java:77)
at com.pmease.quickbuild.grid.GridJob.run(GridJob.java:129)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

robinshen ADMIN ·

Please open the server log and check if there is anything printed there around the scheduled time.

robinshen ADMIN ·
mbachhav-intel ·

Hi Robin,

After fixing REST api URL. Checkout steps works fine. also able to trigger the compile when repository changes.

However I am not able to build the pull open pull requests. This is how I defined the configuration:
build_pull_req.png

robinshen ADMIN ·

Any error printed in server log? NOte that the user name and password setting in this repository is for https rest url, instead of ssh url

mbachhav-intel ·

Hi Robin,

Yes I am using http login credentials.
I enabled schedule of checking every 2 min with build condition of "when repo changes"
When I submit a pull request no activity at QB server.

When I manually run the configuration to build open pull request I get following error on web browser :

Message: Cannot run program "C:/Program" (in directory "/qb/server/bin"): error=2, No such file or directory

Root cause:
"
com.pmease.quickbuild.QuickbuildException: Cannot run program "C:/Program" (in directory "/qb/server/bin"): error=2, No such file or directory
at com.pmease.quickbuild.execution.Commandline.execute(Commandline.java:321)
at com.pmease.quickbuild.execution.Commandline.execute(Commandline.java:235)
at com.pmease.quickbuild.plugin.scm.git.GitRepository.getShortBranches(GitRepository.java:412)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository.getShortBranches(BitbucketServerRepository.java:117)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$cfd21626.CGLIB$getShortBranches$7( )
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$cfd21626$$FastClassByCGLIB$$93b71565.invoke( )
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:261)
at com.pmease.quickbuild.plugin.scm.bitbucketserver.BitbucketServerRepository$$EnhancerByCGLIB$$cfd21626.getShortBranches( )
at com.pmease.quickbuild.DefaultBuildEngine.requestBuild(DefaultBuildEngine.java:1835)
at com.pmease.quickbuild.DefaultBuildEngine.requestBuild(DefaultBuildEngine.java:1742)
at com.pmease.quickbuild.web.page.configuration.ConfigurationPage$4.onClick(ConfigurationPage.java:207)
at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:187)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:272)
at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:220)
at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:179)
at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:165)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:719)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:63)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:253)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:162)
at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at com.pmease.quickbuild.web.MainServlet.service(MainServlet.java:135)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.equinox.http.helper.FilterServletAdaptor$FilterChainImpl.doFilter(FilterServletAdaptor.java:56)
at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:365)
at org.eclipse.equinox.http.helper.FilterServletAdaptor.service(FilterServletAdaptor.java:37)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at com.pmease.quickbuild.Quickbuild$DisableTraceFilter.doFilter(Quickbuild.java:1139)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)

robinshen ADMIN ·

What is your QB version?

mbachhav-intel ·

my QB version is 8.0.38

robinshen ADMIN ·

Looks git executable path you've specified in git plugin setting (administration / plugin management) is incorrect.

mbachhav-intel ·

Hi Robin,

This is my path to git executable.
My QB server runs on linux, however build agent is windows.
When I dont have "Build Open Pull Requests" checked then bitbucker server repository checkout works fine on windows QB agent.
When I check the box "Build Open Pull Requests", Build request submission fails because the executable is not found. This is likely because server is trying to connect to Bitbucket repository and uses wrong git executable path. However I am specified that build should happen on windows QB agent.
Do I need to specify two different paths for linux system(QB server) and windows Qb agent.

plugin_management.JPG

Error at server side:

2019-07-30 12:42:10,212 [qtp994837284-69] ERROR com.pmease.quickbuild.web.WicketConfig - Error handling wicket request.
org.apache.wicket.WicketRuntimeException: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at [ [Component id = run]] on component [ [Component id = run]] threw an exception
at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:282)
at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:220)
at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:179)
at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:165)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:719)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:63)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:210)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:253)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:162)
at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at com.pmease.quickbuild.web.MainServlet.service(MainServlet.java:135)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.equinox.http.helper.FilterServletAdaptor$FilterChainImpl.doFilter(FilterServletAdaptor.java:56)
at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:365)
at org.eclipse.equinox.http.helper.FilterServletAdaptor.service(FilterServletAdaptor.java:37)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at com.pmease.quickbuild.Quickbuild$DisableTraceFilter.doFilter(Quickbuild.java:1139)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)

robinshen ADMIN ·

This is the reason, the "build open pull request" option requires to check open pull requests on QB server. Please modify it something like below:
${groovy:node.isServer()?"/path/to/git": "C:\Program Files\Git\bin\git.exe"}

Here "/path/to/git" needs to point to git executable on QB server.

mbachhav-intel ·

Hi Robin,
Using groovy script did fix the executable path. However with this my server and agent uses different paths for git.
This might cause problem when we have windows agent and linux agents.
good idea to keep it simply git? depending on the terminal environment correct executable will be picked.

robinshen ADMIN ·

You may script it like below:
${groovy:node.getAttribute("os.name").toLowerCase().startsWith("win")?: "C:\Program Files\Git\bin\git.exe": "/path/to/git"}

mbachhav-intel ·

Hi Robin,

How should I configure the bitbucket server repository so it only build pull requests for a specific branch?

robinshen ADMIN ·

It does not have such functionality for now, please file an improvement request at track.pmease.com

drdt ·

I created variables for this so I can make many other things platform-specific:

sysIsWindowsNode: ${groovy: node.getAttribute( "os.name" ).toLowerCase().startsWith( "windows" ); }
sysIsMacOSNode: ${groovy: node.getAttribute( "os.name" ).toLowerCase().startsWith( "mac" ); }

etc.

then:

sysGitPath: ${groovy: vars.get("sysIsWindowsNode").asBoolean() ? "C:\Program Files\Git\bin\git.exe": "/path/to/git"; }
sysWorkspaceRoot: ${groovy: vars.get("sysIsWindowsNode").asBoolean() ? "\hostname\shared\workspace\path": "/shared/workspace/path"; }
sysDotBatExtension: ${groovy: vars.get("sysIsWindowsNode").asBoolean() ? ".bat" : ""; }

mbachhav-intel ·
CaoFangyuan ·

Hi Robin,

I know for the pull request trigger quick build in certain branch, it's not supported in quick build yet. But I wonder if I can get the merge branch name in quick build through quick build system variable? Like if my pull request id merge branch A to branch B, I can get B through quick build variable, then I can do different build way according to the branch name. My quick build version is 9.0.21. Thanks.

steveluo ADMIN ·

Hi@CaoFangyuan

From traditional way, it is impossible to get those values. The better way to trigger a build by pull request is via webhook. When a pull request is created or updated, build can start automatically (no schedule any more) and you can add any variables you want there and the later build workflow can use them.

The feature has already been implemented for GitHub plugin, you may look at the below page to see if it can help in your case:

We'll add this feature to BitBucket server and BitBucket cloud in next patch release soon. The tickets have been filed:

and

CaoFangyuan ·

Thanks, I will try.