Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-36029

multibranch-job deleted when bitbucket communication fails

      I'm trying out the "Bitbucket team/project" feature: I have an issue where some of my jobs keeps being deleted and recreated randomly, and it seems to be related to situations where communicating with bitbucket fails. I would not expect Jenkins to delete my multibranch-job when e.g. Bitbucket or some network link is down.

      Relevant log:

      Proposing ansible-docker
      Connecting to https://bitbucket.org using hidden-org-name/****** (hidden-org-name bitbucket credentials)
      Looking up hidden-org-name/ansible-docker for branches
      Checking branch jenkins-test from hidden-org-name/ansible-docker
      Met criteria
      ERROR: Failed to create or update a subproject ansible-docker
      com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: Communication error: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequest(BitbucketCloudApiClient.java:421)
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRepository(BitbucketCloudApiClient.java:173)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.getRepositoryType(BitbucketSCMSource.java:254)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.observe(BitbucketSCMSource.java:372)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieveBranches(BitbucketSCMSource.java:326)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:279)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:146)
      	at jenkins.scm.api.SCMSource.retrieve(SCMSource.java:230)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:175)
      	at jenkins.branch.MultiBranchProjectFactory$BySCMSourceCriteria$1.call(MultiBranchProjectFactory.java:157)
      	at jenkins.branch.MultiBranchProjectFactory$BySCMSourceCriteria$1.call(MultiBranchProjectFactory.java:154)
      	at jenkins.branch.OrganizationFolder.withSCMSourceCriteria(OrganizationFolder.java:255)
      	at jenkins.branch.MultiBranchProjectFactory$BySCMSourceCriteria.recognizes(MultiBranchProjectFactory.java:154)
      	at jenkins.branch.OrganizationFolder$1$1.complete(OrganizationFolder.java:165)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator.add(BitbucketSCMNavigator.java:198)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator.visitSources(BitbucketSCMNavigator.java:175)
      	at jenkins.branch.OrganizationFolder.computeChildren(OrganizationFolder.java:125)
      	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:157)
      	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:122)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
      	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:992)
      	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
      	at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
      	at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
      	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
      	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
      	at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828)
      	at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116)
      	at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
      	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
      	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
      	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
      	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequest(BitbucketCloudApiClient.java:412)
      	... 20 more
      Caused by: java.io.EOFException: SSL peer shut down incorrectly
      	at sun.security.ssl.InputRecord.read(InputRecord.java:505)
      	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
      	... 33 more
      
        Evaluating orphaned items in hidden-org-name on Bitbucket
        Will remove ansible-docker as it is #1 in the list
        Finished: SUCCESS
      
      

          [JENKINS-36029] multibranch-job deleted when bitbucket communication fails

          Asgeir Frimannsson created issue -

          Counterpart of JENKINS-34776

          Antonio Muñiz added a comment - Counterpart of JENKINS-34776

          I have a lot of repositories in our team account (kinda 30) and I'm very annoyed that I have to re-run folder computation 10 times to get all my repos configured.
          Will some retry logic work here?

          Vladimir Rozhkov added a comment - I have a lot of repositories in our team account (kinda 30) and I'm very annoyed that I have to re-run folder computation 10 times to get all my repos configured. Will some retry logic work here?
          Michael Fowler made changes -
          Priority Original: Major [ 3 ] New: Critical [ 2 ]

          Javier Martín added a comment - - edited

          We are experiencing this issue as well. As we delegate our User Directory to JIRA, when this instance is not available an Unauthorized Error 401 appears rising the following error:

          com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 401: No Autorizado.
          {"errors":[

          {"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.AuthenticationSystemException"}

          ]}
          at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:382)
          at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranches(BitbucketServerAPIClient.java:258)
          at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:384)
          at jenkins.scm.api.SCMSource.fetch(SCMSource.java:245)
          at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:75)
          at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:206)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:410)
          Finished: FAILURE

          Then we need to run the folder computation again and all build numbers are restarted. We use this parameter as a complement to version number so there is a way to retain build numbers when this happens? This is not a case when a Jenkinsfile is not present in a branch (I assume when this happens the multibranch job is deleted), this is a temporary issue with the scan credentials and I think it wouln't be that way.

          Javier Martín added a comment - - edited We are experiencing this issue as well. As we delegate our User Directory to JIRA, when this instance is not available an Unauthorized Error 401 appears rising the following error: com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 401: No Autorizado. {"errors":[ {"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.AuthenticationSystemException"} ]} at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:382) at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranches(BitbucketServerAPIClient.java:258) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:384) at jenkins.scm.api.SCMSource.fetch(SCMSource.java:245) at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:75) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:206) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410) Finished: FAILURE Then we need to run the folder computation again and all build numbers are restarted. We use this parameter as a complement to version number so there is a way to retain build numbers when this happens? This is not a case when a Jenkinsfile is not present in a branch (I assume when this happens the multibranch job is deleted), this is a temporary issue with the scan credentials and I think it wouln't be that way.

          jaomp this is not the same issue. The issue is about ssl handshake failure and yours is about auth failure. Make sure you've setup credentials correctly.

          Meanwhile, I'm working on PR to fix the SSL handshake issue.

          Vladimir Rozhkov added a comment - jaomp this is not the same issue. The issue is about ssl handshake failure and yours is about auth failure. Make sure you've setup credentials correctly. Meanwhile, I'm working on PR to fix the SSL handshake issue.

          The title of the issue is "multibranch-job deleted when bitbucket communication fails" and I think this is the same issue. The log says unauthorized request, but this is due to a communication problem between bitbucket and jira and therefore bitbucket-branch-source-plugin behaves in the same way as the open issue. The credentials are placed correctly and works fine almost always.

          Maybe I neet to create another issue because this is only because SSL handshake, but seems pretty close to me, the problem is that when bitbucket communication fails jenkins deletes all multibranch-jobs and restarts build numbers when the computation folder runs again.

          Javier Martín added a comment - The title of the issue is "multibranch-job deleted when bitbucket communication fails" and I think this is the same issue. The log says unauthorized request, but this is due to a communication problem between bitbucket and jira and therefore bitbucket-branch-source-plugin behaves in the same way as the open issue. The credentials are placed correctly and works fine almost always. Maybe I neet to create another issue because this is only because SSL handshake, but seems pretty close to me, the problem is that when bitbucket communication fails jenkins deletes all multibranch-jobs and restarts build numbers when the computation folder runs again.

          Right, the fix is the same for any "connection issue".

          Antonio Muñiz added a comment - Right, the fix is the same for any "connection issue".

          javi_m: sorry then for misunderstanding.
          Does simple retry fix the issue, how do you think?

          Vladimir Rozhkov added a comment - javi_m : sorry then for misunderstanding. Does simple retry fix the issue, how do you think?

          Antonio Muñiz added a comment - - edited

          Already fixed in github-branch-source https://github.com/jenkinsci/github-branch-source-plugin/pull/57

          The fix needed here is similar.

          Antonio Muñiz added a comment - - edited Already fixed in github-branch-source https://github.com/jenkinsci/github-branch-source-plugin/pull/57 The fix needed here is similar.

            stephenconnolly Stephen Connolly
            asgeirf Asgeir Frimannsson
            Votes:
            19 Vote for this issue
            Watchers:
            24 Start watching this issue

              Created:
              Updated:
              Resolved: