0% found this document useful (0 votes)
9 views6 pages

DevOps Guide: Maven, Gradle, Jenkins

Uploaded by

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

DevOps Guide: Maven, Gradle, Jenkins

Uploaded by

kaelixdarnov
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

**DevOps Experiments: Detailed Step-by-Step Guide for Beginners on Windows (Without

Using IDEs)**

---

### **1. Introduction to Maven and Gradle**

#### Step-by-Step:

**Install Java:**
1. Download JDK (e.g., Java 17): [Link]
[Link]
2. Set Environment Variable:
- JAVA_HOME: C:\\Program Files\\Java\\jdk-17
- Add %JAVA_HOME%\\bin to PATH

**Install Maven:**
1. Download: [Link]
2. Extract to: C:\\apache-maven-3.x.x
3. Set Environment Variables:
- M2_HOME: C:\\apache-maven-3.x.x
- Add %M2_HOME%\\bin to PATH
4. Check: mvn -v

**Install Gradle:**
1. Download: [Link]
2. Extract to: C:\\gradle-x.x
3. Set Environment Variables:
- GRADLE_HOME: C:\\gradle-x.x
- Add %GRADLE_HOME%\\bin to PATH
4. Check: gradle -v

---

### **2. Working with Maven**

#### Create Maven Project:


```bash
mvn archetype:generate -DgroupId=[Link] -DartifactId=myapp -
DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
```

#### Navigate and Understand:


```bash
cd myapp
notepad [Link]
```
(Observe dependencies and plugins)

#### Add Dependency:


Add to `<dependencies>` block in `[Link]`:
```xml
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
```

#### Build Project:


```bash
mvn clean install
```

---

### **3. Working with Gradle**

#### Initialize Project:


```bash
gradle init --type java-application
```

#### Understand [Link]:


```bash
notepad [Link]
```

#### Add Dependency:


```groovy
dependencies {
testImplementation 'junit:junit:4.13.2'
}
```
#### Run Task:
```bash
gradle build
```

---

### **4. Build and Run Java Application with Maven and Gradle**

#### Maven:
```bash
cd myapp
mvn clean package
java -cp target/[Link] [Link]
```

#### Gradle:
```bash
cd gradleproject
gradle build
java -cp build/libs/[Link] [Link]
```

---

### **5. Introduction to Jenkins**

#### Install Jenkins:


1. Download Jenkins WAR: [Link]
2. Run:
```bash
java -jar [Link]
```
3. Access: [Link]
4. Copy password from printed logs or from:
```bash
C:\Users\<username>\.jenkins\secrets\initialAdminPassword
```

---

### **6. Continuous Integration with Jenkins**


#### Configure Maven in Jenkins:
1. Manage Jenkins → Global Tool Configuration
2. Add Maven installation

#### Create CI Pipeline:


1. Create Freestyle Project → Configure
2. Source Code Management: Git → Add repo URL
3. Build → Invoke top-level Maven targets → Goal: `clean install`

---

### **7. Configuration Management with Ansible**

#### Install WSL:


```bash
wsl --install
```

#### Inside WSL:


```bash
sudo apt update && sudo apt install ansible -y
```

#### Create Playbook (`[Link]`):


```yaml
- hosts: localhost
tasks:
- name: Print Hello
debug:
msg: "Hello from Ansible"
```

#### Run Playbook:


```bash
ansible-playbook [Link]
```

---

### **8. Jenkins CI + Ansible Deployment**

#### Jenkins:
- Post-build step: Archive artifacts
#### Ansible Playbook:
```yaml
- hosts: localhost
tasks:
- name: Copy Artifact
copy:
src: /var/lib/jenkins/jobs/<job>/builds/.../[Link]
dest: /deployment/path/
```

---

### **9. Introduction to Azure DevOps**

#### Set Up Account:


1. [Link] → Sign Up
2. Create new Project

---

### **10. Creating Build Pipelines**

#### Azure Pipelines:


1. Create New Pipeline → GitHub Repo → YAML → Paste:
```yaml
trigger:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: Maven@3
inputs:
mavenPomFile: '[Link]'
goals: 'clean install'
```

---

### **11. Creating Release Pipelines**


#### Set Up:
1. Azure Pipelines → Releases → New Pipeline
2. Artifact: Pick from build
3. Task: Azure App Service Deploy
4. Secrets: Azure Key Vault task → Link key vault

---

### **12. Final DevOps Pipeline and Best Practices**

#### Pipeline Summary:


1. Code in GitHub
2. Build via Azure Pipelines (Maven/Gradle)
3. Deploy via Azure Release Pipelines

#### Best Practices:


- Use `.env` or Key Vault for secrets
- Test before deploy
- Use branches and pull requests

You might also like