DEVOPS LAB PROGRAM
DEVOPS LAB PROGRAM
S
AM
R
G
O
PR
B
S
AM
R
G
O
STEP5:Lets see Procedure to install MAVEN & GRADLE
a) First make sure JDK current version is installed
PR
https://www.oracle.com/java/technologies/downloads/?er=221886#jdk23-wi
ndows
Then set environment variable path both user and system
■ Have a JDK installation on your system. Either set the JAVA_HOME
B
b) To install apache maven pls go to link as in below and download zip file of
U
bin
https://maven.apache.org/download.cgi
VT
c) To unzip the Source zip archive
Run in Windows cmd prompt
unzip apache-maven-3.9.9-bin.zip
If don't want to run directly extract the file to Program Files
S
“Add the bin directory of the created directory apache-maven-3.9.9 to the
AM
PATH environment variable”
R
Run this command in CMD prompt
G
mvn --v(2 hyphen)
2. Open a second File Explorer window and go to the directory where the
Gradle distribution was downloaded. Double-click the ZIP archive to
VT
expose the content. Drag the content folder gradle-8.12.1 to your newly
created C:\Gradle folder.
Alternatively you can unpack the Gradle distribution ZIP into C:\Gradle
using an archiver tool of your choice or run command with path folder
where the folder is created.
unzip apache-maven-3.9.9-bin.zip
Or can directly extract the zip file.
3. Configure your system environment
4. Finally type the command gradle –v to check if the gradle is installed.
S
AM
R
G
O
PR
B
LA
U
VT
PROGRAM-2
Working with Maven: Creating a Maven Project, Understanding the POM File,
Dependency Management and Plugins
STEP3:In Screen shown above, click near the entry place of Filter and type
“apache” or select catalog as Internal
We want a simple maven JAR based application. So, we will choose the
“maven-archetype-quickstart” artifact to create the project.
S
AM
R
STEP4: Enter
G
Group Id:com.program2.maven
O
Artifact Id:program2-example-jar
PR
Keep snapshot as it is
B
LA
U
VT
Package:com.program2.maven.program2
S
AM
R
G
O
PR
You be able to see the automation build happening for Maven Jar Project
LA
U
VT
It asks for Configuration confirmation just click Y
S
The RESULT be as in below
AM
R
G
O
PR
S
AM
R
G
O
PR
S
AM
R
G
Description
O
What is groupId in maven ?
PR
groupId identifies a particular project uniquely across all projects, so we should follow a naming
convention. A very simple and commonly used way of doing this is to use the reverse of your
domain, i.e. com.javarewind.maven.
A good way of maintaining the integrity of groupId is to use the project structure. In case the project
B
consists of multiple modules then every module should append an identifier to the parent groupId.
i.e. com.javarewind.maven, com.java rewind.spring, com.javarewind.struts .. etc.
LA
than we have to take the name of the jar as suggested by its distribution.
Archetype is a Maven project templating toolkit which tells the maven the type of project we are
going to create. Archetype enables the maven to create a template project of the user's choice so
that the user can get the project up and running instantly.
“archetype:generate” generates a new project from the provided archetype or updates the actual
project if using a partial archetype. Maven provides a number of predefined archtypes, see more
details from Maven Documentation.
—---------------------------------------------------------------------------------------------------------------------------
HOW POM.XML LOOKS IS AS IN SCREEN BELOW
S
AM
R
G
O
PR
B
LA
U
VT
PROGRAM3:Working with Gradle: Setting Up a Gradle Project,
Understanding Build Scripts (Groovy and Kotlin DSL), Dependency
Management and Task Automation
S
AM
For changing to a current directory the command is
cd pgm3
Now run
R
gradle init
After execution of command the screen shows as in below where we opt
G
for build type select as 1
O
PR
B
LA
After selecting Implementation language it will ask for Java version and
project name
After providing version and project name
Select application structure as Single application structure and Domain
Specific Language as Kotlin
S
AM
R
G
O
After every procedure is over it shows Build successful
PR
B
LA
U
It will take atleast 3-5 minutes to run the configuration script we have set
through steps finally the output be as in below If You want to see the
structure of an application run the command as tree
S
AM
R
G
O
PR
project and run java application you will get Hello World Message
S
AM
R
G
O
PR
STEP6:
Type the command
VT
gradle build
Now to get exact program output of our java file Locate to build gradle File from ur
local repository and Copy paste the code as in below shown in red color
plugins {
id("java-library")
id("maven-publish")
id("application")
}
S
AM
application {
mainClass.set("com.pgm4.test.App") // Use .set() for properties
}
R
repositories {
mavenCentral()
G
// Uncomment if you need to publish locally
// mavenLocal() O
}
PR
dependencies {
testImplementation("junit:junit:4.13.2") // Use Kotlin syntax for dependencies
}
B
group = "com.pgm4.test"
version = "0.0.1-SNAPSHOT"
LA
description = "pgm4"
java.sourceCompatibility = JavaVersion.VERSION_11 // Consider upgrading
publishing {
U
publications {
create<MavenPublication>("maven") {
VT
from(components["java"])
}
}
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
tasks.withType<Javadoc>().configureEach {
options.encoding = "UTF-8"
}
S
gradle run
AM
You will get Output as
Hello World! Welcome to pgm4
R
G
O
PR
B
LA
G
O
PR
B
LA
U
VT
STEP3: Goto Jenkins MSI Installer click on it u opt for “Run service as Local System”
S
AM
R
G
XX Need not to Provide Account & Password XX
O
PR
STEP4: Choose a port as 8080 and test the port and click Next
B
LA
U
VT
S
AM
R
G
O
PR
STEP5:It takes current jdk version thats available for safer side once goto cmd prompt and type
command
java –version
If matching click next
If failed to accept download jdk version 17 to 21 any of it
B
https://www.oracle.com/java/technologies/javase/jdk21-archive-downloads.html
LA
U
VT
S
AM
R
G
O
STEP6: Click NEXT after doing above step you will get screen as in Below again continue to click Next
PR
B
LA
U
VT
STEP7: The popup allow format comes for Java Automation Server allow it click install —-----> Finally
Click Finish
S
AM
R
G
O
PR
confi
Final step very important Once It will ask for Administrator Passowrd so u should locate as in
directory mention copy paste as in mention in file location:
C:\ProgramData\Jenkins\.jenkins\secrets\initialAdminPassword and paste password as in
mentioned belows administration passowrd
U
VT
Then select Install Suggested Plugins it starts to install as in shown below
S
AM
R
G
O
PR
Then it asks for minimum registration You can skip and continue as admin
B
LA
U
VT
Final screen be:
S
AM
R
G
O
PR
PROGRAM6 :Continuous Integration with Jenkins: Setting Up a CI Pipeline, Integrating Jenkins with
Maven/Gradle, Running Automated Builds and Tests
How Is Jenkins Used for Continuous Integration?
B
With Jenkins, developers can easily detect and fix integration issues early,
U
S
using testing frameworks like JUnit, TestNG, and Selenium. This ensures
AM
that any issues introduced during development are quickly detected and
reported, allowing developers to address them promptly.
● Pipeline as code: Jenkins Pipeline allows users to define their entire CI/CD
pipeline as code using a domain-specific language called “Groovy.” This
R
makes the pipeline easily versionable, shareable, and more maintainable.
● Distributed builds: Jenkins supports distributed builds across multiple
G
build agents, which allows for faster and more efficient build processes by
distributing the workload across multiple machines.
O
● Plugins and extensibility: Jenkins offers a vast ecosystem of plugins that
extend its functionality, allowing users to customize and adapt Jenkins to
PR
their specific needs. Plugins are available for various tasks, such as
integrating with different VCS, build tools, notification systems, and more.
● Notifications and reporting: Jenkins can send notifications through various
channels like email, Slack, or other messaging systems to keep the team
B
informed about build status, test results, and potential issues. It also
generates reports and visualizations for various metrics, such as test
LA
● REST API: Jenkins exposes a REST API that enables users to interact with
Jenkins programmatically, allowing for integration with external tools,
automation, and custom applications.
S
● Short feedback loops: The automation provided by Jenkins CI allows
AM
developers to receive immediate feedback on the success or failure of their
code changes. Rapid feedback helps in identifying problems early,
ensuring that they can be addressed before they become more difficult and
time-consuming to resolve.
R
● Automated workflows: Jenkins CI can be configured to trigger automated
workflows based on specific events, such as code commits or pull
G
requests. This enables a seamless and efficient flow of work, helping teams
maintain a high level of productivity and consistency.
O
PR
However, there are potential concerns associated with using Jenkins CI:
for potential issues, and troubleshooting any problems that arise. This
maintenance can be time-consuming and may require dedicated personnel
VT
S
AM
R
G
O
PR
STEP2: Select Plugins
B
LA
U
VT
S
AM
R
G
O
PR
STEP6: Now lets not select Maven Project as new Item as we already have Maven project
in local systems lets see how we can run the Maven Project with POM.XML
B
G
Scroll down to ‘Build‘ option. Click on ‘Add Build Step‘ and choose the
O
value ‘Invoke top-level Maven targets‘ from the drop down list.
PR
B
LA
U
VT
d) After selecting Invoke top-level Maven targets opt for proper environment
version as in set in previous steps in my case its MAVEN_HOME
S
AM
e) Enter Goal as
R
clean install
G
f) Before you save and apply just below Goal there is Advance option add
pom.xml path O
PR
B
LA
U
Goto pom.xml of your particular pgm and take path in my case its
C:\Users\CMRIT-ISE-L209-009\Desktop\IS147\pgm4\pom.xml
VT
After all Steps is over click on Build button the output be as in below
S
AM
R
To see either click on build texts and goto console output or u can goto
G
dashboard and opt to see build scripts.
O
PR
B
LA
U
VT
PROGRAM7: Configuration Management with Ansible: Basics of Ansible:
Inventory,Playbooks, and Modules, Automating Server Configurations with
Playbooks, Hands-On: Writing and Running a Basic Playbook.
How Do I Install Ansible on Ubuntu?
S
STEP 1: Configure Ansible Control Node
AM
The Ansible control node is a system used to connect to and manage Ansible
host servers. Proceed with the steps below to set up the control node on the main
R
server:
G
1. Create an administrator-level user for the control node. Use the adduser
command:
O
PR
sudo adduser [username]
S
AM
A membership in the sudo group allows the user to utilize the sudo command to
perform administrative tasks.
R
G
sudo su [username]
O
Note: The Ansible control node can be a dedicated server, a local machine, or a
PR
virtual machine running Ubuntu.
The Ansible control node uses SSH to connect to hosts. Generate an SSH key
LA
1. Enter the command below using the Ansible control node command line:
U
ssh-keygen
VT
Note: If an SSH key pair with the same name already exists, SSH displays a
warning asking the user to decide whether to overwrite it. Overwriting makes
the previous SSH key pair unusable, so ensure the old keys are no longer
needed before confirming.
2. When prompted, provide a passphrase. While adding a strong passphrase is
recommended, pressing Enter allows the user to skip the passphrase creation.
The system generates the public/private key pair and prints the randomart image.
S
AM
R
G
O
PR
Ansible hosts are remote servers managed by the Ansible control node. Each
B
host must have the control node's SSH public key into authorized_keys directory.
LA
1. Use the following ssh-copy-id command on the control node to copy the public
U
key to a host:
VT
ssh-copy-id [username]@[remote-host]
Replace [username] with an existing administrative user on the host system and
[remote-host] with the remote host domain or IP address. For example, to copy
the key to the user ansible on the host with the local IP address 192.168.0.81,
type:
To know IP type command
2. Type yes and hit Enter when asked whether to continue connecting to an
S
authenticated host.
AM
3. Enter the remote host account password.
R
G
O
PR
B
LA
The utility uploads the public key to the remote host account.
Use the APT package manager to install the Ansible package on the control node
system:
VT
Check that Ansible was successfully installed on your Ubuntu system using the
S
ansible command:
AM
ansible --version
R
The output displays the Ansible version number, the location of the configuration
G
file, the path to the executable, and other information.
O
PR
B
Once Ansible is installed on the control node, set up an inventory file to allow
Ansible to communicate with remote hosts. The inventory file contains all the
U
information about the remote hosts managed through the Ansible control node.
VT
Note: For an in-depth overview of creating files on remote hosts, refer to our
article How to Create a File In Ansible.
Follow the steps below to create an inventory file on the control node:
S
The [local] line allows for the creation of categories to organize local hosts. The
AM
following example adds a local host using its local IP address 192.168.0.81 and
sorts it into the servers category:
R
G
O
PR
ansible-inventory --list -y
U
To ensure the Ansible control node can connect to the local hosts and run
commands, use the following ansible command to ping the hosts from the
control node:
S
Note: When a user connects to the remote hosts for the first time, Ansible asks
AM
for confirmation that the hosts are authentic. To confirm the authenticity, enter
yes when prompted.
R
The output confirms the successful connection.
G
O
PR
B
LA
The Ansible control node is now set up to control the connected remote hosts.
Conclusion
U
After following the steps in this guide, you have successfully installed Ansible on
VT
Ubuntu and can execute commands and playbooks on remote hosts. The guide
provided instructions for setting up the Ansible control node and connecting it
with the hosts via SSH.
S
AM
R
G
STEP2: Click on Start Free after that u get screen as in below
O
PR
B
LA
U
Click on Create one, If u have Github account u can Sign in using github account
better way is to create one account
VT
R
G
O
PR
B
LA
S
AM
R
G
O
STEP7:This step is the important once where u fill your Academic Details
properly where u provide College email id as in provided by your Individual
PR
colleges later the verification code again comes
B
LA
U
VT
After proper college email is given u get verification mail with link to mail u have
provided
S
AM
R
G
Click on link sent O
After u Click The screen be as in Below
PR
B
LA
U
VT
S
AM
R
G
O
PR
B
LA
G
number of services now our target is Azure Devops
After above selection it once again reverifies name and email just click Continue
After it U get a Screen
VT
U
LA
B
PR
O
G
R
AM
S
S
AM
R
G
You will be able to see Organization is Created O
PR
B
LA
U
S
AM
R
G
O
PR
B
STEP3: to create simple hellow world maven project type command as in below
mvn archetype:generate -DgroupId=com.dineshonjava -DartifactId=Javateam
VT
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
S
AM
R
G
O
STEP3: to add files from local to github Follow the procedure
a) First create a repository in github as maventestazure
PR
b) Then come to gitbash and type
git init
git add .
git commit -m “azure pipeline example”
B
S
AM
R
G
O
STEP6: After creating Pipeline select type of repo as Github
PR
B
LA
U
VT
STEP7: It asks for minimum signin verification after that ur screen be as in below select
required repository there to run maven project in my case its maventest123
S
AM
R
G
O
STEP8: AFTER REQUIRED REPO IS SELECTED the screen be as in below
PR
B
LA
U
VT
Drag the screen down check once again the selected repository is correct or not then
click on Approve and Install
S
AM
R
STEP9: It again verifies signin verification of microsoft account
G
You be able to see starter pipeline select for Maven
O
PR
B
LA
U
VT
After selecting maven it asks for save and run just click on it
S
AM
R
G
O
Finally You be able to see tasks running its failed bec we shld mention proper path
For pom.xml
PR
B
LA
U
VT
S
AM
R
The commits will also be visible in github
G
O
WE can download and also see individual Raw Log Reports
PR
B
LA
U
VT
If pipeline permission error comes please complete the registration form of Parallel Jobs after 2 working
days(48hrs) u be able to run pipelines for private projects same happens to be for public Projects.
Program11: Creating Release Pipelines: Deploying Applications to Azure App Services,
Managing Secrets and Configuration with Azure Key Vault, Hands-On:
Continuous Deployment with Azure Pipelines.
STEP1: Click on Organization setting and click on Pipeline Settings You get screen as in below
S
AM
R
G
O
PR
STEP3: NOw you be able to see the visibility of Release for any pipeline creation as in screen
below.
S
AM
STEP4: YOu can run simple test plans
R
G
O
PR
B
LA
U