0% found this document useful (0 votes)
6 views18 pages

devops_batch2_all_experiments

The document outlines a series of experiments focused on establishing automated build and deployment pipelines using tools like Azure DevOps, Jenkins, Maven, Gradle, and Ansible. Each experiment includes aims, prerequisites, procedures, outputs, and results, demonstrating the setup of CI/CD pipelines, regression testing, and infrastructure automation. The overall goal is to enhance software quality, streamline delivery processes, and improve deployment reliability.

Uploaded by

rajesh21590845
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views18 pages

devops_batch2_all_experiments

The document outlines a series of experiments focused on establishing automated build and deployment pipelines using tools like Azure DevOps, Jenkins, Maven, Gradle, and Ansible. Each experiment includes aims, prerequisites, procedures, outputs, and results, demonstrating the setup of CI/CD pipelines, regression testing, and infrastructure automation. The overall goal is to enhance software quality, streamline delivery processes, and improve deployment reliability.

Uploaded by

rajesh21590845
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Experiment 1: Establish an automated software build pipeline in Azure using

Maven

**Aim:** To establish an automated software build pipeline using Maven in Azure DevOps, enabling
efficient and continuous integration of code changes.

**Prerequisites:**
- Azure DevOps account with access to Azure Pipelines
- Source code repository containing a Maven project
- Basic understanding of Maven build lifecycle
- Permissions to create and manage pipelines

**Procedure:**
1. Sign in to Azure DevOps and create a new project if one doesn't exist.
2. Navigate to Repos and push your Maven project code to Azure Repos Git.
3. Click on Pipelines > New Pipeline.
4. Select the repository containing the Maven project.
5. Choose "Starter pipeline" or existing YAML template.
6. Modify the YAML with Maven tasks as below:

```
trigger:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean install'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
```

7. Save and run the pipeline to verify it compiles and packages successfully.

**Output:** A running pipeline that compiles code, runs tests, and generates reports on each push to
the main branch.

**Result:** An automated build pipeline is successfully established in Azure DevOps using Maven.
Experiment 2: End-to-end Maven build pipeline with regression testing in Azure

DevOps

**Aim:** To develop an Azure DevOps Maven pipeline that includes regression testing for ensuring
code quality during each build.

**Prerequisites:**
- Azure DevOps setup with permissions
- Maven project with integrated regression test suite (JUnit/TestNG)
- Prepared test data if needed

**Procedure:**
1. Push your Maven project to Azure Repos.
2. Include a robust regression test suite in the test folder.
3. In Azure Pipelines, create a pipeline using the YAML configuration.
4. Add tasks for compiling, executing tests, and publishing results:

```
trigger:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: Maven@3
inputs:
goals: 'clean verify'
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/target/surefire-reports/TEST-*.xml'
```

5. Configure the test environment via pipeline variables and service connections.
6. Use pipeline extensions for better test visualization (e.g., Test Plans).

**Output:** Comprehensive test results including regressions are published, and detailed reports are
accessible in the Azure DevOps dashboard.

**Result:** A complete Maven build pipeline with regression testing is implemented, supporting high
software quality assurance.
Experiment 3: Create CI pipeline using Jenkins

**Aim:** To create a Jenkins-based Continuous Integration (CI) pipeline to automatically build, test,
and report application changes.

**Prerequisites:**
- Jenkins installed and configured with necessary plugins
- Git repository URL of your application
- Maven or Gradle installed on Jenkins agents

**Procedure:**
1. Open Jenkins and create a new Pipeline project.
2. Configure the SCM section with your Git repository.
3. Write a Jenkinsfile (declarative pipeline) to automate CI:

```
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git 'https://github.com/user/repo.git'
}
}
stage('Build') {
steps {
sh 'mvn clean install'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
}
}
```

4. Save and build the pipeline.

**Output:** Jenkins executes checkout, build, and test processes automatically.

**Result:** CI pipeline in Jenkins facilitates early error detection and rapid feedback.
Experiment 4: Create a CD pipeline in Jenkins and deploy in Cloud

**Aim:** To configure a Jenkins Continuous Deployment (CD) pipeline to deploy applications to a


cloud platform such as AWS or Azure.

**Prerequisites:**
- Jenkins with required plugins (SSH, cloud CLI tools)
- Maven/Gradle project and cloud credentials (e.g., AWS IAM, Azure Service Principal)

**Procedure:**
1. Create a Jenkins Pipeline project.
2. Write a Jenkinsfile to build and deploy your application:

```
pipeline {
agent any
environment {
CLOUD_CREDENTIALS = credentials('cloud-creds-id')
}
stages {
stage('Build') {
steps {
sh 'mvn package'
}
}
stage('Deploy') {
steps {
sh 'scp target/app.war user@cloudhost:/var/www/'
sh 'ssh user@cloudhost "sudo systemctl restart tomcat"'
}
}
}
}
```
3. Configure credentials securely in Jenkins.

**Output:** Application is built and deployed to the cloud after successful build.

**Result:** Automated deployment pipeline in Jenkins is successfully established.


Experiment 5: Develop application using Gradle

**Aim:** To build a simple Java application using Gradle as the build tool, managing dependencies
and tasks efficiently.

**Prerequisites:**
- JDK and Gradle installed

**Procedure:**
1. Create a project using:
```
gradle init --type java-application
```
2. Modify build.gradle to add dependencies:

```
dependencies {
implementation 'com.google.guava:guava:30.1-jre'
testImplementation 'junit:junit:4.13.2'
}
```

3. Compile the code:


```
gradle build
```

4. Run unit tests:


```
gradle test
```

5. Generate a JAR file:


```
gradle jar
```

**Output:** Build completes and deployable JAR is available in build/libs.

**Result:** Gradle successfully compiles, tests, and packages the application.


Experiment 6: Jenkins CD pipeline to deploy to cloud

**Aim:** To automate cloud-based deployments using Jenkins CD pipeline.

**Prerequisites:**
- Jenkins setup
- Deployment server/cloud instance
- SSH access or cloud CLI configured

**Procedure:**
1. Configure pipeline to include build and deploy stages.
2. Use SCP/SSH or cloud CLI to deploy to instance.
3. Use Jenkins credentials manager for secrets.

**Output:** Automated deployment of builds to cloud servers.

**Result:** CD pipeline improves speed and reliability of cloud deployments.


Experiment 7: Implement Jenkins CD pipeline for streamlined delivery

**Aim:** To ensure seamless software delivery using Jenkins CD pipeline.

**Prerequisites:**
- Jenkins configured with agents
- Build tool (Maven/Gradle) installed

**Procedure:**
1. Define stages for build, testing, packaging, and deployment.
2. Use post-build actions to trigger cloud deployments.
3. Ensure rollback steps in case of failure.

**Output:** Code flows from commit to production without manual intervention.

**Result:** Efficient Jenkins-based CD implementation enhances software delivery.


Experiment 8: CD pipeline considerations in cloud

**Aim:** To explore key considerations when deploying applications using Jenkins CD pipelines in
cloud environments.

**Prerequisites:**
- Basic cloud and Jenkins knowledge

**Procedure:**
1. Secure secrets using credential vaults.
2. Ensure CI validation before deployment.
3. Implement health checks post-deployment.
4. Monitor application logs and metrics.
5. Use immutable artifacts and infrastructure as code.

**Output:** Resilient and secure cloud deployments.

**Result:** Best practices strengthen CD pipeline reliability.


Experiment 9: Full CD pipeline using Jenkins and cloud

**Aim:** To create a robust Jenkins CD pipeline that automates build, test, package, and deploy
stages using cloud services.

**Prerequisites:**
- Jenkins, cloud CLI (Azure/AWS), Maven

**Procedure:**
1. Write Jenkinsfile with sequential stages:

```
pipeline {
agent any
stages {
stage('Build') { steps { sh 'mvn clean install' } }
stage('Test') { steps { sh 'mvn test' } }
stage('Package') { steps { sh 'mvn package' } }
stage('Deploy') {
steps {
sh 'az webapp deploy --name myapp --src-path target/app.war'
}
}
}
}
```

2. Configure service connections and secrets.


3. Monitor and alert on deployment status.

**Output:** Fully automated CI/CD pipeline with cloud deployment.

**Result:** Accelerated delivery cycles with higher stability.


Experiment 10: Importance of Ansible playbooks

**Aim:** To emphasize the role of structured Ansible playbooks in infrastructure automation.

**Prerequisites:**
- Ansible installed
- Basic YAML understanding

**Procedure:**
1. Use modular roles and reusable variables.
2. Maintain consistent formatting and comments.
3. Use handlers and conditionals effectively.
4. Maintain idempotency in all tasks.

**Output:** Clear, efficient, and reliable automation scripts.

**Result:** Structured playbooks reduce human error and increase maintainability.


Experiment 11: Utilize regression test results in Azure Maven pipeline

**Aim:** To use regression testing outputs for improving software reliability in Azure DevOps.

**Prerequisites:**
- Test suites with meaningful coverage
- Azure Pipelines test reporting enabled

**Procedure:**
1. Execute regression tests via Maven.
2. Collect results using PublishTestResults.
3. Set quality gates or approval steps based on test results.
4. Trigger alerts for failures or anomalies.

**Output:** Comprehensive feedback on application stability.

**Result:** Regression tests enable proactive bug detection and quality improvements.
Experiment 12: Ansible playbook for web app setup

**Aim:** To automate the deployment and configuration of a web application using Ansible.

**Prerequisites:**
- Ansible and target host configured with SSH access

**Procedure:**
1. Create inventory file defining web hosts.
2. Write playbook:

```
- hosts: webservers
become: yes
tasks:
- name: Install Apache
apt:
name: apache2
state: present

- name: Copy web content


copy:
src: index.html
dest: /var/www/html/index.html
```

3. Run the playbook:

```
ansible-playbook -i inventory webapp.yml
```

**Output:** Web application installed and accessible.


**Result:** Automated, repeatable deployment of web applications using Ansible.

You might also like