Monday, April 4, 2022

Module 8: Create Java Web Project using Maven & setup in Github repo

 Please work on setting up a Java project (using maven) in Github by following below steps. You need to complete lab exercise # 1 first before you do this one.


Please note I am sending this in advance but I will demo this when we meet in next time.


Pre-requistes:

If you don't have a github account, You need to create an account in http://github.com

Implementation steps:


1. after login into bitbucket, click on + and Click on Create Repository





2. enter the repo name as DemoApp, make sure it is private, Include read me option - Click on Add a README  and follow by create button






3. Click on create repository.



  1. In the upper-right corner of any page, click your profile photo, then click Settings.

    Settings icon in the user bar

  2. In the "Access" section of the sidebar, click  SSH and GPG keys.

  3. Click New SSH key or Add SSH key.SSH Key button

  4. In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air".

  5. Paste your key into the "Key" field.The key field

  6. Click Add SSH key.The Add key button

  7. If prompted, confirm your GitHub password.Sudo mode dialog




4. 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 - https://devopstraining2000.blogspot.com/2022/04/module-5-how-to-connect-to-ec2.html

 

5. Now type  ssh-keygen (and then simply enter four times, do not give any password)


 

 

6. copy the content of public key executing below command in Gitbash.

 

sudo cat ~/.ssh/id_rsa.pub

 

7. 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.

 
 

8. 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. 

9. 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_github_repo_you_created> using ssh option in the github

and enter yes when prompted  


 

  
   10. Now after cloning, type ls -al command

11. It will show a folder with repo name..

12. navigate to repo folder by below command: 

    cd DemoApp

13. use below command to create Java project using Maven. Maven is the build for creating and building java projects.

mvn archetype:generate -DgroupId=com.mkyong -DartifactId=MyWebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

14. type ls -al to see the new folder called MyWebApp

 
   15. 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 github"

 

19. Now perform below command to push from local repository to remote repository.

git push



 

now you should see all your files in Guthub repo you created under source link.

 


No comments:

Post a Comment

Module 34: Understanding Terraform

  Terraform is a platform-agnostic tool that allows you to build, change, and version infrastructure securely and efficiently. Terraform is ...