The Jenkins CI server can be integrated with BitBucket by using the concept of deployment keys. In BitBucket go to Settings > Deployment Keys. Add a new public key. Make sure you are adding an openssh compatible public key otherwise the key won’t be accepted. Once this is done you need to test the read-only cloning capability using this approach.
ssh-agent (ssh-add /home/user1/ssh_keys/my_private_key; git clone git@bitbucket.org:my_user/my_project.git)
This command basically attempts to make a clone from the BitBucket server using the private key you specified as ‘my_private_key’. Since we are using the ssh-agent command to wrap the other two commands the key is loaded, the clone command is executed and then immediately the key is unloaded. If your cloning process failed you know that something is wrong. Remember you need the private key in openssh format as well.
If the above command gave you the cloned repository, go ahead and use this private key inside the Jenkins server.
Please do refer to BitBucket documentation link has more details on the exact steps.