I am trying to clone a python repository using the following code. I am trying to automate the process of cloning for certain automation tasks required for code analysis:
import subprocess
def clone_bitbucket_repo(username, password, repository_url,destination_path):
command = ['git' ,'clone', repository_url, destination_path]
# Set up environment variables for authentication
env_variables = {
'BITBUCKET_USERNAME': username,
'BITBUCKET_PASSWORD': password
}
# Execute the git clone command
try:
subprocess.check_output(command, shell=True, env=env_variables)
print("Repository cloned successfully!")
except subprocess.CalledProcessError as e:
print(f"Error cloning repository: {e}")
# Example usage
bitbucket_username = 'username'
bitbucket_password = 'password'
destination_path = 'path/of/folder/'
clone_bitbucket_repo(bitbucket_username, bitbucket_password, repository_url,destination_path)
Please let me know if can have a solution to reolve this error.
Thanks,
Kompal