devops
devops
Register Number:
of sixth Semester
Git-Internals
1
3 Maven Installation
6 Jenkins Pipeline
AIM:
To learn about basic git commands.
COMMANDS:
sowmya@SOWMYA-11 MINGW64 /d/devops/git (master)
$ git init test
Initialized empty Git repository in D:/devops/git/test/.git/
Commit one
Commit Three
bak/test.txt | 1 +
1 file changed, 1 insertion(+)
commit 31894013168229eb1a108f39855bf2aff6aacf3b
Author: Rsowmya26 <[email protected]>
Date: Mon Mar 4 21:44:36 2024 +0530
Commit Two
new.txt | 1 +
test.text | 1 +
2 files changed, 2 insertions(+)
commit d1d95daf2f2331968e676b5b7a6cad20cf17e485
Author: Rsowmya26 <[email protected]>
Date: Mon Mar 4 21:41:44 2024 +0530
Commit one
test.txt | 1 +
1 file changed, 1 insertion(+)
AIM:
To learn Git commands, facilitating effective version control in projects.
COMMANDS:
1. Clone a Repository:
To copy a repository from GitHub to your local machine:
git clone https://github.com/username/repository.git
2. Add Changes:
To stage changes for the next commit:
git add .
3. Commit Changes:
To save the staged changes to the local repository:
git commit -m “Your commit message”
4. Push Changes to GitHub:
To upload committed changes to your GitHub repository:
git push origin branch-name
5. Pull Changes from GitHub:
To retrieve changes from a GitHub repository to your local repository:
git pull origin branch-name
6. Create a New Branch:
To create a new branch:
git checkout -b new-branch
7. Switch Branches:
To switch between branches:
git checkout branch-name
8. Merge Branches:
To merge changes from one branch into another:
git merge branch-name
AIM:
To install Apache Maven on Windows.
STEPS:
Step 1: Download Maven Zip File and Extract
Click on the Download button.
Now right-click on the downloaded file and click on extract here to extract the file.
Now copy the extracted folder.
Now paste the copy folder in your windows drive in the Program files folder.
Now open the folder apache maven.
Now after opening the folder then copy the address of the folder in program files.
RESULT:
Thus, Maven is installed and ready to use on the Windows system.
EX NO: 4 Gradle Installation and Understanding Build using Gradle
DATE:
AIM:
To install Apache Maven on Windows.
STEPS:
Step 1. Download the latest Gradle distribution
• The distribution zip file comes in two flavors:
1. Binary-only
2. Complete, with docs and sources
Step 2. Unpack the distribution Microsoft Windows users:
• unpack the Gradle distribution ZIP into C:\Gradle using an archiver tool of your choice.
Step 3. Configure your system environment.
Microsoft Windows users
In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System
Settings -> Environmental Variables.
Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-8.6\bin. Click OK to
save.
Step 4. Verify your installation Open a console (or a Windows command prompt) and run gradle -v to run
gradle and display the version.
$ gradle -v
Understanding Build using Gradle
Steps to create Java application using Gradle
Step 1. Initializing the Project
Step 2. Understanding the Directory layout
Step 3. Review the Gradle Files
Step 4. Review the Code
Step 5. Run the App
Step 6. Bundle the App
Step 7. Publish a Build Scan
settings.gradle
build.gradle
.gitignore
build.gradle
Adding code for testing
• create the directory structure src/test/java, then the same package structure com.devop
• create a Gradlesampletest.java source file, and inside add this test class which uses the JUnit 4 library.
Build directory and Reports directory after build cmd in Project directory
Publish a Build Scan
• Again run the build task with scan
• can consult a test report generated in build/reports/tests/test
• Open the index.html file in a browser and see that 1 test was executed with 0 failures. Or
• Execute gradlew build --scan to see detailed report
RESULT:
Thus Gradle is installed on windows and executed simple gradle project.
EX NO: 5 Jenkins Installation and Creation of freestyle project
DATE:
AIM:
To install Jenkins and to create a freestyle project.
STEPS:
INSTALLATION
1. Browse to the official Jenkins download page. Under the Downloading Jenkins section is a
list of installers for the long-term support (LTS) version of Jenkins. Click the Windows link
to begin the download.
2. Once the download is complete, run the jenkins.msi installation file.
3. The setup wizard starts. Click Next to proceed.
6. Enter the port number you want Jenkins to run on. Click Test Port to check if the selected
port is available, then click Next to continue.
7. Select the directory where Java is installed on your system and click Next to proceed.
8. Select the features you want to install with Jenkins and click Next to continue.
Unblock Jenkins
After completing the installation process, you have to unblock Jenkins before you can
customize and start using it.
1. In your web browser, navigate to the port number you selected during the installation
using the following address:
http://localhost:[port number]
2. Navigate to the location on your system specified by the Unblock Jenkins page.
3. Open the initialAdminPassword file using a text editor such as Notepad.
5. Paste the password in the Administrator password field on the Unblock Jenkins page and
click Continue to proceed.
Customize Jenkins
Once you unlock Jenkins, customize and prepare the Jenkins environment.
1. Click the Install suggested plugins button to have Jenkins automatically install the most
frequently used plugins.
2. After Jenkins finishes installing the plugins, enter the required information on the Create
First Admin User page. Click Save and Continue to proceed.
3. On the Instance Configuration page, confirm the port number you want Jenkins to use
and click Save and Finish to finish the initial customization.
4. Click the Start using Jenkins button to move to the Jenkins dashboard.
Creation of freestyle project
1. Access Jenkins from the internet and log in by using the credentials.
2. Give the name of the project and select the freestyle project as show in the image
below. And click on ok after selecting.
3. You need to configure all the required configurations required for the project which you
want to build.
RESULT:
Thus Jenkins is installed and created a simple freestyle project.
EX NO: 6 Jenkins Pipeline
DATE:
AIM:
To create a pipeline in Jenkins.
STEPS:
1. On the Jenkins dashboard, click on New Item. Then enter an item name, for
example, ‘pipeline’ and select the ‘Pipeline’ project. Then click on, OK.
2. You need to configure all the required configurations required for the project which you
want to build.
3. Under pipeline section, select “pipeline script from SCM” from the drop down
menu.
AIM:
To create Maven Build pipeline in Azure
STEPS:
Step 1: Set up Azure DevOps Project
From the Azure Portal, browse to All services, search for DevOps and select Azure DevOps.
This will open the Azure DevOps dashboard.
Next, click My Azure DevOps Organizations and provide your Azure credentials. You will be
brought to a page where you can create a new organization as shown below. Once here, click
on the blue Create new organization button.
On the next page, provide a name for the organization.. Once done, click Continue.
Creating an Azure DevOps Project
The next step is creating a project. A project is a container for the pipeline .
On the project creation page, provide a name for your project in the Project name field. For
this project. Confirm the creation of the project by clicking the + Create Project button.
At this point, your Azure DevOps workspace (project + organization) has been created.
Building an Azure DevOps Build Pipeline
Now that you have an Azure DevOps organization and project set up, you can now create a build
pipeline inside. It’s where you will create builds to perform various tasks like compiling code,
bringing in dependencies and more.
3.You will then be prompted for where your code is stored. In this Project, the code is stored in a
GitHub repository. Select GitHub. This is the place where code is stored and the triggers for
invoking the build will come from.
4. Once you click on GitHub, you’ll be prompted to provide your GitHub account credentials as
shown below.
5. Next, confirm the step where you are asked to authorize Azure Pipelines. This ensures Azure
DevOps has permission to access your GitHub repos.
Linking a GitHub Repo to the Build Pipeline
Once you’ve provided Azure DevOps permission to your GitHub account, now link a GitHub repo
to the build pipeline.
1.Select the empty GitHub repo you have created for this Project. Choose the repository where your
Maven project is hosted.
2. Allow the project to read, write and check source code from the repository you selected earlier.
Then confirm this process by clicking Approve & Install.
RESULT:
Thus, Maven Build pipeline is created in Azure and executed successfully.
EX NO:8 Create a Maven Build pipeline in Jenkins
DATE:
AIM:
To execute maven project using Jenkins pipeline.
STEPS:
1. Create a Maven project for Bubble sort
# Create a new directory for your Maven project
mkdir bubble-sort-project
cd bubble-sort-project
# Run tests
mvn test
5. Upload to GitHub
Create a new repository on GitHub and place src folder and POM.Xml in that
repository.
Now create a Jenkinsfile and write the following script
pipeline {
agent any
stages {
stage('Build') {
steps {
// Checkout the code from your Git repository
bat 'git clone https://github.com/Rsowmya26/dev.git'
stage('Run') {
steps {
bat 'java -cp target/classes com.example.bubblesort.BubbleSort'
}
}
}
}
3. Ansible ad hoc commands enable you to perform tasks on remote nodes without having
to write a playbook.
4. Check the connection with local host
5. the -m parameter is the module option. Ping is the adhoc command and the second
parameter all represents all hosts in the inventory file. The output of the command is
shown below:
6. find the git version in remote window
RESULT:
Thus ansible has been installed in wsl ubuntu and keeping windows as host node all the
adhoc commands are executed and verified.
EX NO : 10 INSTALLATION OF VLC MEDIA PLAYER IN WINDOWS HOST
DATE:
AIM:
To install ansible in wsl ubuntu and to connect to one windows host and install VLC media
player in windows host.
STEPS:
1. In windows host enable winrm
Get-NetConnectionProfile
Enable WinRM -Enable-PSRemoting
RESULT:
Thus VLC media player is installed in windows host from WSL Ubuntu ansible control
node.