If your repository is private, you’ll need to add credentials to authorize Jenkins with your Git provider. Navigate to Dashboard -> Manage Jenkins -> Credentials -> System -> Global credentials (unrestricted).
When you click “Add credentials” button choose “SSH Username with private key” in “Kind” field.
“Username” – username or email
“Private Key” -> click “Enter directly“
To add Private Key you need public and private key.
After this, you will find both jenkins and jenkins.pub files in your user directory.
Open jenkins.pub file, copy entire value and paste it in your profile configuration on your git provider (example for GitHub is presented below).
Open jenkins file (without pub extension), copy entire value and paste it in Private Key field in Jenkins credentials configurator.
After saving the form, you should see a list of credentials. Save the ID of the created element because we will need it later.
Create new pipeline
On the main dashboard click “New Item” and add new Pipeline
Below is the script I have created to build previously created application.
Click “Build Now” button on the left navigation bar and see the magic.
We can configure Jenkins to synchronize with Git events and our builds can be executed when pull request have been created or when we push something to master branch.
Why are we doing this?
Before I explain, please modify your application code to the presented below.
var z =
Console.WriteLine($"It works");
and push it to your repository.
Click “Build Now” button again.
If we had it connected to Git events, we would know immediately when our code has failed, right after someone pushed it to the main branch.
Everything we just did is called CI. Not so scary, right :)?
Introduction to Jenkins and Pipelines
What is Pipeline?
Pipeline is a solution that automatically build, test and deploy an application. We can split Pipeline to (CI) and (CD) Pipelines.
CI – Continous Integration
CD – Continous Delivery/Deployment
CI – helps maintain code quality by catching errors early in the development process.
CD – streamlines the process of delivering code changes to production environments efficiently and reliably.
Use it in practice!
Today, I’ll show you how to use Jenkins to create CI for your application.
To follow this tutorial, go to https://www.jenkins.io/doc/book/installing/ and install Jenkins.
Create console application in Visual Studio
Push it to your remote repository. You can see an example on https://github.com/MajewskiPawel/app-ci-cd
Use Jenkins!
If your repository is private, you’ll need to add credentials to authorize Jenkins with your Git provider. Navigate to Dashboard -> Manage Jenkins -> Credentials -> System -> Global credentials (unrestricted).
When you click “Add credentials” button choose “SSH Username with private key” in “Kind” field.
“Username” – username or email
“Private Key” -> click “Enter directly“
To add Private Key you need public and private key.
After this, you will find both jenkins and jenkins.pub files in your user directory.
Open jenkins.pub file, copy entire value and paste it in your profile configuration on your git provider (example for GitHub is presented below).
Open jenkins file (without pub extension), copy entire value and paste it in Private Key field in Jenkins credentials configurator.
After saving the form, you should see a list of credentials. Save the ID of the created element because we will need it later.
Create new pipeline
On the main dashboard click “New Item” and add new Pipeline
Below is the script I have created to build previously created application.
Run it!
Click “Build Now” button on the left navigation bar and see the magic.
We can configure Jenkins to synchronize with Git events and our builds can be executed when pull request have been created or when we push something to master branch.
Why are we doing this?
Before I explain, please modify your application code to the presented below.
and push it to your repository.
Click “Build Now” button again.
If we had it connected to Git events, we would know immediately when our code has failed, right after someone pushed it to the main branch.
Everything we just did is called CI. Not so scary, right :)?
Archives
Understanding K-Nearest-Neighbors (KNN) – Essential Machine Learning Algorithm
2024-10-06A Step-by-Step Guide to Web Scraping for Beginners
2024-07-12Categories
Meta