I am trying to create a Jenkins job that will trigger a shell script via the option Send files or execute commands over SSH in Jenkins. The following is the main part of my shell script:
#!/bin/bash
BRANCH=$1
cd /vm/deployment
git clone myuser@bitbucket.org/myuser/proj.git" target="_blank" rel="nofollow">https://myuser@bitbucket.org/myuser/proj.git
#updating the common property files
cd /vm/deployment/swcm-properties
git reset --hard HEAD
#git pull ${BRANCH}
git fetch && git checkout ${BRANCH}
git pull
My problem here is that the execution fails since I am unable to pass the password and username for the repository for the clone to work.
When I try to execute the following shell script, which is saved on the server, I get the following error:
#!/bin/bash
git clone https://$uname:$pass@bitbucket.org/mysuer/myrepo.git
remote: Invalid username or password
fatal: Authentication failed for 'https://:@bitbucket.org/
/myrepo.git/'
What is the best approach to pass the username and password and trigger a git clone from a Bitbucket repository using Jenkins.