Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lesson26/HelloDevops/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>hello-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
15 changes: 15 additions & 0 deletions lesson26/HelloDevops/src/main/java/com/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com;

/**
* Hello DevOps!
*/
public class App {
private static final String MESSAGE = "Hello DevOps!";
public App() {}
public static void main(String[] args) {
System.out.println(MESSAGE);
}
public String getMessage() {
return MESSAGE;
}
}
30 changes: 30 additions & 0 deletions lesson26/HelloJenkins/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>hello-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
15 changes: 15 additions & 0 deletions lesson26/HelloJenkins/src/main/java/com/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com;

/**
* Hello Jenkins!
*/
public class App {
private static final String MESSAGE = "Hello Jenkins! CODEBY TEST CHANGE";
public App() {}
public static void main(String[] args) {
System.out.println(MESSAGE);
}
public String getMessage() {
return MESSAGE;
}
}
30 changes: 30 additions & 0 deletions lesson26/HelloWorld/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>hello-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
15 changes: 15 additions & 0 deletions lesson26/HelloWorld/src/main/java/com/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com;

/**
* Hello world!
*/
public class App {
private static final String MESSAGE = "Hello World!";
public App() {}
public static void main(String[] args) {
System.out.println(MESSAGE);
}
public String getMessage() {
return MESSAGE;
}
}
71 changes: 71 additions & 0 deletions lesson26/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
pipeline {
agent any

tools {
maven 'Maven'
}

stages {
stage('Detect Changed Apps') {
steps {
script {
def changedFiles = bat(script: "git diff --name-only HEAD~1 || echo ''", returnStdout: true).trim().split('\n')

def apps = ['HelloWorld', 'HelloJenkins', 'HelloDevops']
def changedApps = []

apps.each { app ->
if (changedFiles.any { it.startsWith("${app}/") }) {
changedApps << app
}
}

if (changedApps.isEmpty()) {
changedApps = apps
}

env.CHANGED_APPS = changedApps.join(',')
echo "Изменённые приложения: ${env.CHANGED_APPS}"
}
}
}

stage('Build & Run') {
parallel {
stage('HelloWorld') {
when { expression { env.CHANGED_APPS.contains('HelloWorld') } }
steps {
dir('HelloWorld') {
echo "=== Сборка HelloWorld ==="
bat 'mvn clean package'
echo "=== Запуск HelloWorld ==="
bat 'java -jar target/hello-app-1.0-SNAPSHOT.jar'
}
}
}
stage('HelloJenkins') {
when { expression { env.CHANGED_APPS.contains('HelloJenkins') } }
steps {
dir('HelloJenkins') {
echo "=== Сборка HelloJenkins ==="
bat 'mvn clean package'
echo "=== Запуск HelloJenkins ==="
bat 'java -jar target/hello-app-1.0-SNAPSHOT.jar'
}
}
}
stage('HelloDevops') {
when { expression { env.CHANGED_APPS.contains('HelloDevops') } }
steps {
dir('HelloDevops') {
echo "=== Сборка HelloDevops ==="
bat 'mvn clean package'
echo "=== Запуск HelloDevops ==="
bat 'java -jar target/hello-app-1.0-SNAPSHOT.jar'
}
}
}
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.