-
Create a new repository:
- Go to GitHub and log in.
- Click on the
+
icon in the top right corner and selectNew repository
. - Enter a repository name and description.
- Choose to make the repository public or private.
- Click
Create repository
.
-
Clone the repository:
- Copy the repository URL.
- Open a terminal and run:
git clone https://github.com/your-username/your-repository.git
- Navigate into the repository directory:
cd your-repository
-
Generate a new SSH key:
- Open a terminal and run:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- Follow the prompts to save the key (default location is recommended).
- Open a terminal and run:
-
Add the SSH key to the ssh-agent:
- Start the ssh-agent in the background:
eval "$(ssh-agent -s)"
- Add your SSH key to the ssh-agent:
ssh-add ~/.ssh/id_rsa
- Start the ssh-agent in the background:
-
Add the SSH key to your GitHub account:
- Copy the SSH key to your clipboard:
cat ~/.ssh/id_rsa.pub
- Go to GitHub and navigate to
Settings
>SSH and GPG keys
. - Click
New SSH key
, provide a title, and paste your key. - Click
Add SSH key
.
- Copy the SSH key to your clipboard:
-
Install GitHub plugin:
- Go to
Manage Jenkins
>Manage Plugins
. - In the
Available
tab, search forGitHub
and install theGitHub Plugin
.
- Go to
-
Configure GitHub credentials:
- Go to
Manage Jenkins
>Manage Credentials
. - Add a new credential with your GitHub username and personal access token.
- Go to
-
Create a new Jenkins job:
- Go to
New Item
, enter a name, and selectFreestyle project
. - Under
Source Code Management
, selectGit
. - Enter your repository URL and select the credentials you added earlier.
- Go to
-
Build triggers:
- Under
Build Triggers
, checkGitHub hook trigger for GITScm polling
.
- Under
-
Save and build:
- Save the job configuration.
- Click
Build Now
to test the setup.