2

I have a spring-boot application running on docker environment that connect on Git repository to get application's configuration. My problem is from time to time the application gives an error when try to get the .properties file. It's strange because the same application if I change the user and password come back to work.

Error

2021-06-20 15:42:57.229  WARN 1 --- [nio-8888-exec-1] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.

org.eclipse.jgit.api.errors.TransportException: https://####@bitbucket.org/####/cup-configuration-files: git-upload-pack not permitted on 'https://####@bitbucket.org/####/cup-configuration-files/'
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]

I've tried this solution but it didn't work: create basedir directory.

application.yml

server:
    port: 8888
spring:
    application:
        name: config-server
    cloud:
        config:
            server:
                git:  
                    basedir: temp
                    password: ####
                    username: ####
                    uri: https://#######@bitbucket.org/########/cup-configuration-files
                    searchPaths: '{application}'
management:
        endpoints:
          web:
            exposure:
              include: "*"

I've already check inside docker container if temp directory has all permissions.

When I run the same application on my local environment with mvn spring-boot:run command it works.

PS: Git version locally is different from docker environment. I don't know if could be the problem.

Aldo Inácio da Silva
  • 824
  • 2
  • 14
  • 38

2 Answers2

0

I've created a cup-configuration-files directory, initialized it with git and made a git pull to get all the files and on application.yml I put the uri as file:

application.yml:

server:
    port: 8888
spring:
    application:
        name: config-server
    cloud:
        config:
            server:
                git:  
                    basedir: temp
                    password: ######
                    username: ######
                    uri: file:/cup-configuration-files
                    searchPaths: '{application}'
management:
        endpoints:
          web:
            exposure:
              include: "*"
Aldo Inácio da Silva
  • 824
  • 2
  • 14
  • 38
0

I was facing same error i.e. "git-upload-pack not permitted" when I was cloning Bitbucket repository in Spring Tool Suit 4 (STS) via wizard "Clone a Git repository". I struggled for many hours only to realize that we need to use generated password via add app password link in Bitbucket.

Here are more details on how to resolve "git-upload-pack not permitted" error.

Bitbucket

  1. Go to Bitbucket home

  2. To your bottom left corner click on your account icon. It will display pop-up menu one of which will be "Personal settings". Click on the same. It will take you to your account settings.

  3. On the Bitbucket personal account settings page, you will see menu link "App passwords", click on the same. On the right side panel, App passwords page will be displayed.

  4. On the right side page, you will see "Create app password" button. Click on the same. It will show details to add app password.

GitHub

If you are using GitHub, then be informed that GitHub has deprecated passwords and you need to create a personal access token in GitHub as stated here. (Please refer this answer)

Atul
  • 3,778
  • 5
  • 47
  • 87