Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot put aar to remote repository maven-publish

Joe
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 14, 2022

I have try to publish AAR to a private remote repo [Bitbucket] with publish task, but keep getting 403 Forbidden, even though I set all the required credentials

- I'm making sure that credentials have a right permission to push

publishing {
    publications {
        release(MavenPublication) {
            groupId = LIBRARY_PACKAGE
            artifactId = LIBRARY_NAME
            version = LIBRARY_VERSION

            afterEvaluate {
                from components.release
            }
        }
    }

    repositories {
        maven {
            credentials {
                username = "xxxx"
                password = "xxxx"
            }

            name = "7-map-android"
            url = "https://api.bitbucket.org/2.0/repositories/{$OWNER_NAME}/{$REPO_NAME}/src/releases"
        }
    }
}

 

execute task:
./gradlew :module:publish
error:
* What went wrong:
Execution failed for task ':map:publishReleasePublicationTo7-map-androidRepository'.
> Failed to publish publication 'release' to repository '7-map-android'
   > Could not PUT 'https://api.bitbucket.org/2.0/repositories/{$OWNER_NAME}/{$REPO_NAME}/src/releases/net/appsynth/seven/map/0.6.0/map-0.6.0.aar'. Received status code 403 from server: Forbidden

 
Source:

https://developer.android.com/studio/publish-library/upload-library#create-pub

3 answers

1 vote
Jose Valdés
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 12, 2022

I'm in the same situation, any updates here?

0 votes
vikash singh tomar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 8, 2023

Any updates on this?

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 8, 2023

Hi Joe,

We do not manage or support third-party plugins, unfortunately. You would need to reach out on the Gradle forums for further updates - our API does not support the "PUT" method that is used by the plugin which is what is causing the issue:
https://discuss.gradle.org/ 

Cheers!

- Ben (Bitbucket Cloud Support)

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 28, 2022

G'day Joe!

Welcome to the Bitbucket Cloud Community! :)

I am responding here as I have noticed that you are yet to receive a response from our community.

The "403 Forbidden" error usually relates to the permissions or to the authentication credentials that are being passed through to the API request.

Can I confirm if you are using an App Password in the credentials? API calls require you to use an App Password, and this App Password must be configured with the necessary permissions to make changes to your repository (in this case WRITE), we have a guide here explaining how to configure an App Password:

https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/

Once you have configured the App Password, you would use it in the same manner as you would have previously used your GIT username/password (which has been deprecated) ie

user = owner_name

password = AppPassword

Hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

Pedro Henrique Sousa Lopes
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 29, 2022

I received status code 405 from server: Method Not Allowed

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 29, 2022

Hey @Ped the 405 Error tells us that authentication has succeeded, however, either the URL or the request method is incorrect.

Are you able to try POST instead of PUT as the request method and see if this works?

Cheers!

- Ben (Bitbucket Cloud Support)

Pedro Henrique Sousa Lopes
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 30, 2022

By default Maven uses the PUT method.
I didn't find a way to change the maven method.

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2022

Hi @Pedro Henrique Sousa Lopes ,

If the intention of the script is to update an existing repository (ie upload files to this repository), unfortunately only the POST method is accepted by the /2.0/repositories endpoint when uploading files to a repository.
I have tested this on my end and was able to upload a file successfully to my repository with the POST method in the following format:

curl -u {Username}:{AppPassword} -X POST https://api.bitbucket.org/2.0/repositories/{WorkspaceID}/{RepoSlug}/src -F uploadtest.txt=@uploadtest.txt

When I have tried using the PUT method with either an access token or an AppPassword, I receive either a 403 or 405 error (depending on the URL, ie with repo folder path /workspaceid/reposlug/src vs full file path /workspaceid/reposlug/src/filename.txt).

When checking our API Documentation for the /2.0/repositories endpoint, the PUT method is only accepted when updating the name of an existing repository or creating a new empty repository, this does not include uploading files to an existing repository.

The problem, therefore, appears to be with the API request method that the plugin uses rather than an issue with the endpoint itself. As we do not provide support for third-party plugins, I would suggest reaching out to the Gradle community if you are not able to get a response from our other Atlassian community members to see if there is a way of modifying the request method to POST instead:

https://discuss.gradle.org/

Hope this helps to steer you in the right direction.

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events