Sunday, February 23, 2020

How to push a code change into a GitHub repository? | push code changes into GitHub using Git bash

Let us see how to push a code change using Git bash or iTerm from Jenkins EC2 instance into GitHub.

After configuring a freestyle job or pipeline using Jenkins for building and deployment, you would like to make a code change to make sure Jenkins have started automated builds/deployments.

Pre-requisites:
Implementation steps:
1. Login to Jenkins EC2 instance first. Make sure you are inside EC2 instance.
2. Type below command to see if you have already cloned your repository.
ls -al

you should see the repo name. once you see the repo name, cd into repo folder

(If you don't see any GitHub Repo folder already cloned, you need to clone from GitHub by executing below command:

git clone git@github.com:user_name/your_repo.git

now go inside repo folder.

3. cd youreponame

change repo_name per your name of the repo you created in GitHub.

Go into below folder by typing the command:
4. Now try to get latest code changes from GitHub into local repo by performing below command:
git pull
5. cd MyWebApp/src/main/webapp
Now you can edit below file to reflect changes in Tomcat
6. sudo vi index.jsp

Change Hello world into below yellow highlighted:
<html>
<body>
<h2>Howdy Folks !!! Welcome to DevOps!</h2>
</body>
</html>

7. press escape, enter :wq!
8. git add index.jsp
9. git commit -m "made change to jsp"
10. git push

Now Login to GitHub and verify the code changes you made are pushed into your repo in GitHub.

1 comment: