BitBucket is one of the popular git-based version control systems. BitBucket is very good example for Software-as-a-service, hosted on cloud. Let us learn how to setup a Java web project in BitBucket.
Git is a purely distributed version control system. Click here to learn more about Git and its advantages over other SCMs.
Pre-requistes:
If you don't have an bitbucket account, You need to create an account in bitbucket.org.Implementation steps:
1. after login into bitbucket, click on + and Click on Create Repository
3. Click on create repository.
4. now click on your avatar (left bottom of the screen, BitBucket settings-> security--> ssh keys
5. now go to your laptop, open git bash for windows laptop or iTerm (for iMac laptop) and connect to Jenkins EC2 instance using Git bash.
How to connect, refer this url - http://www.cidevops.com/2018/
6. Now type ssh-keygen (and then simply enter four times, do not give any password)
If you already have keys generated, you can use existing key. You don't have to over write the old key.
7. copy the content of public key executing below command in Gitbash.
sudo cat ~/.ssh/id_ed25519.pub
8. go to click on Add key from step # 3, and paste the content of public key. give some name as mySSH key. click on Add key.
9. Now click on repo you created in step # 1. Click on Clone and copy the SSH url. Do not select HTTPS Url. The url will be from your repo you created under Clone link.
10. go back to Gitbash windows connected to Jenkins EC2, execute the below command. Paste the SSH url you copied above.
git clone <ssh_url_from_bitbucket_repo_you_created>
11. Now after cloning, type ls -al command
12. It will show a folder with repo name..
14. use below command to create Java project using Maven. Maven is the build for creating and building java projects.
12. It will show a folder with repo name..
13. navigate to repo folder by below command:
cd mybitbucketrepo
cd mybitbucketrepo
14. use below command to create Java project using Maven. Maven is the build for creating and building java projects.
mvn archetype:generate -DgroupId=com.dept.app -DartifactId=MyWebApp -DarchetypeArtifactId=maven-ar chetype-webapp -DinteractiveMode=false
15. type ls -al to see the new folder called MyWebApp
16. type below command to see the newly created project
git status
17. git add *
18. Perform below command to commit the changes to local repository first.
git commit -m "my first project check-in to bitbucket"
git commit -m "my first project check-in to bitbucket"
19. Now perform below command to push from local repository to remote repository.