0% found this document useful (0 votes)
17 views

GitHub and Jenkins basics

Uploaded by

Pavan Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

GitHub and Jenkins basics

Uploaded by

Pavan Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Steps to Push Code to Git Repositories using Command Prompt

Pre-requisites:
1. Download Git from below Link:
https://git-scm.com/download/win/ [Git must be
installed in Local System].
2. Once Git is installed >> SSH Key should be
Added in Git.
Login to Github >> Go to Settings >> User should
be able to see SSH and GPG Keys on Left Side
Panel as per below Screenshot.

Click on SSH and GPG Keys >> User should be able


to see as shown below in same page.

Now Click on New SSH Key and Add SSH Key.


Below are the Steps to Generate SSH Key using Git
bash:
Step1: Launch git bash.
Step2: Type ssh-keygen -t rsa -> Enter -> Enter -
> Enter -> Key will be generated.

Admin@Admin-PC MINGW64 ~
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key
(/c/Users/Admin/.ssh/id_rsa):
/c/Users/Admin/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in
/c/Users/Admin/.ssh/id_rsa.
Your public key has been saved in
/c/Users/Admin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:RWDx9MsZekrqrGMqKoL7tWVvjq51BSlUnz
knk78RAzU Admin@Admin-PC
Now Go to Path as shown above which is
highlighted.
[Path will be changed from System to System].
Open the File which is of Publisher type and user
should be able to see SSH Key which needs to be
added in Git.
[Make sure key is starting with ssh-rsa].
Once SSH key is added, you are good to add your
code to created repository in Git.
Note: We can add as many as ssh keys, if we need
to give permission for someone who can contribute
to our repositories.
Below are the commands to Push Code from
Command Prompt:
Step 1: Open Command Prompt.
Step 2: Go to Folder/Workspace where your
project/files stored.

In my case my project is stored in D: Drive and


User should be in Project Folder.

Step 3: git init >> Command to initialise project


with repository.
Step 4: git status >> To check status.

Since my project is already associated with created


repository, it is showing as Reinitialized existing Git
Repository. If it is not initialized, still you can
proceed and you can initialize later on.
Then I am checking status of files >> All files are
highlighted in Red color because they are not
ready to be committed.
Step 5: git add . Or git add Filename >>
Commands to add all files or To add particular File.
Step 6: git status >> To check status.

Now all files are highlighted in Green color because


all files are ready to be Committed.
Step 7: git commit –m “Comment Message”
Step 8: git status

Now my code is ready to be pushed to Repository.


If Project is not initialised with GIT Repository –
Follow below command to initialise project with GIT
Repository before pushing code to Repository. [It is
a One Time Activity].
If Project is already initialzed you can ignore Step-
9.
Step 9: git remote add origin “Path of Git
Repository”
Now Project will be initialised with GIT Repository
and we are good to push our code.

Step 10: git push origin master [Master >> Branch


Name].
If it asks for credentials >> Enter Valid Username
and Password.

Code is Pushed to initialised GIT Repository.

Other git commands:


git clone “repository path“ – To download or clone
complete repository from git.

git pull origin master – Once repository is cloned


from git to local and we udpate any code for same
repository in git. To get same code to be udpated
in Local and in Eclipse we can use this command.

GitHub and Jenkins basics:


Access:
Note: make sure to have access to rx repositories (https://github.com/orgs/CenturyLink/teams/consumer-repair/repositories)

Also Jenkins Access to check the deployments(https://ne1itcprhas70.ne1.savvis.net:8443/).

If not send a mail/raise request according to below mails.

once you get the access to GutHub repo you should be able to see repair-rx-outage-service project and other RX related
projects.

Cloning and committing:


1. Clone github project to your local as shown below.
Open with GitHub Desktop link should redirect you to install GitHub desktop application and should ask you to provide
path to create local repository.

Alternatively you can create local repo in Desktop application as shown below.

File-> Clone a repository


Once you make changes to your local code you can commit and push the changes from application itself as shown below.
Make sure to check the files to be committed and push to the remote repository.

Trigger Pipeline in Jenkins:

1. Click on new item and follow steps as shown in screen shots.


Note: Please see a kt video done on creating pipeline in below link, and also you can create pipelines by copying the build
configurations of other pipelines.

https://web.microsoftstream.com/video/00430be5-3cde-4567-b08e-fc2863152cbb

Creating fresh Project:


In order to create a fresh SpringBoot project and deploy with CI/CD ppipeline follow the steps below.

Make Sure you have files and folder structure created like below or you can copy from other projects as reference.
The Major changes include making your codebase as Docker and CI/CD pipeline compatible.

In order to do that we basically modify below files and rest all files remain as other projects but we can modify those also based
on our needs.

1. .gitlab-ci.yml
2. Dockerfile
3. Jenkinsfile

Make sure to make changes in above files wherever your application specific keywords are required.
Also make sure to provide github links properly wherever asked in the files.

Running a pipeline:

Once the project and pipeline is created follow below mentioned step to run a pipeline:
You can check the Logs and all like below in each step of pipelines.
Monitor K8S DashBoard:
Once the pipeline is successful you can monitor the app for the same in K8s also as shown.

Note: Make sure to get K8S dashboard access and Token generation Process.

To get the overall picture of GitHub and Jenkins go through the video below which is explained by Anuj as part of the POC of
migration from GitLab to GitHub.

https://web.microsoftstream.com/video/00430be5-3cde-4567-b08e-fc2863152cbb

You might also like