'Jenkinsfile clone bitbucket repo from .sh script

I need to automate a script in jenkins. the script is owned by another department so we have no authority to change it. the script basically has a step where it runs a git clone https://bitbucket.org/{repo}.git.

I'm using a withCredentials gitusernamePassword which is not working. It says authentication failed. When i try to run the git clone manually and passing the username in the URL it works https://[email protected]/{repo}.git. Any ideas how i can set that up by default ? I tried setting the following which didn't work

git config --global user.name git config --global user.email



Solution 1:[1]

Username and password is a deprecated authentication method for API and Git operations in the Bitbucket. You may want to use SSH keys instead of username and password.

As document pointed ; Starting Sep 13, 2021, new Bitbucket users will not be able to use their personal Atlassian account password when using Basic authentication with the Bitbucket API or Git over HTTPS. They will need to use Bitbucket app passwords. Bitbucket users who created an Atlassian account before September 13, 2021 will be able to use their Atlassian account password to authenticate with the Bitbucket API or Git until March 1, 2022.

Reference : https://bitbucket.org/blog/deprecating-atlassian-account-password-for-bitbucket-api-and-git-activity

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oguzhan Aygun