diff --git a/lesson26/HelloDevops/pom.xml b/lesson26/HelloDevops/pom.xml new file mode 100644 index 0000000..de0b40e --- /dev/null +++ b/lesson26/HelloDevops/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + com.mycompany.app + hello-app + 1.0-SNAPSHOT + + 17 + 17 + UTF-8 + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + com.App + + + + + + + \ No newline at end of file diff --git a/lesson26/HelloDevops/src/main/java/com/App.java b/lesson26/HelloDevops/src/main/java/com/App.java new file mode 100644 index 0000000..3150771 --- /dev/null +++ b/lesson26/HelloDevops/src/main/java/com/App.java @@ -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; + } +} \ No newline at end of file diff --git a/lesson26/HelloJenkins/pom.xml b/lesson26/HelloJenkins/pom.xml new file mode 100644 index 0000000..de0b40e --- /dev/null +++ b/lesson26/HelloJenkins/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + com.mycompany.app + hello-app + 1.0-SNAPSHOT + + 17 + 17 + UTF-8 + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + com.App + + + + + + + \ No newline at end of file diff --git a/lesson26/HelloJenkins/src/main/java/com/App.java b/lesson26/HelloJenkins/src/main/java/com/App.java new file mode 100644 index 0000000..bd97b2b --- /dev/null +++ b/lesson26/HelloJenkins/src/main/java/com/App.java @@ -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; + } +} diff --git a/lesson26/HelloWorld/pom.xml b/lesson26/HelloWorld/pom.xml new file mode 100644 index 0000000..de0b40e --- /dev/null +++ b/lesson26/HelloWorld/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + com.mycompany.app + hello-app + 1.0-SNAPSHOT + + 17 + 17 + UTF-8 + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + com.App + + + + + + + \ No newline at end of file diff --git a/lesson26/HelloWorld/src/main/java/com/App.java b/lesson26/HelloWorld/src/main/java/com/App.java new file mode 100644 index 0000000..450ed47 --- /dev/null +++ b/lesson26/HelloWorld/src/main/java/com/App.java @@ -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; + } +} \ No newline at end of file diff --git a/lesson26/Jenkinsfile b/lesson26/Jenkinsfile new file mode 100644 index 0000000..6e929f5 --- /dev/null +++ b/lesson26/Jenkinsfile @@ -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' + } + } + } + } + } + } +} diff --git "a/lesson26/\320\227\320\260\320\277\321\203\321\201\320\272 \320\262\321\201\320\265\321\205 \321\202\321\200\320\265\321\205 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\320\271.jpg" "b/lesson26/\320\227\320\260\320\277\321\203\321\201\320\272 \320\262\321\201\320\265\321\205 \321\202\321\200\320\265\321\205 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\320\271.jpg" new file mode 100644 index 0000000..6b34ac9 Binary files /dev/null and "b/lesson26/\320\227\320\260\320\277\321\203\321\201\320\272 \320\262\321\201\320\265\321\205 \321\202\321\200\320\265\321\205 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\320\271.jpg" differ diff --git "a/lesson26/\320\227\320\260\320\277\321\203\321\201\320\272 \321\202\320\276\320\273\321\214\320\272\320\276 \320\270\320\267\320\274\320\265\320\275\320\265\320\275\320\275\320\276\320\263\320\276 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\321\217.jpg" "b/lesson26/\320\227\320\260\320\277\321\203\321\201\320\272 \321\202\320\276\320\273\321\214\320\272\320\276 \320\270\320\267\320\274\320\265\320\275\320\265\320\275\320\275\320\276\320\263\320\276 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\321\217.jpg" new file mode 100644 index 0000000..905869e Binary files /dev/null and "b/lesson26/\320\227\320\260\320\277\321\203\321\201\320\272 \321\202\320\276\320\273\321\214\320\272\320\276 \320\270\320\267\320\274\320\265\320\275\320\265\320\275\320\275\320\276\320\263\320\276 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\321\217.jpg" differ diff --git "a/lesson26/\320\230\320\267\320\274\320\265\320\275\320\265\320\275\320\270\321\217 \320\262 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\320\270.jpg" "b/lesson26/\320\230\320\267\320\274\320\265\320\275\320\265\320\275\320\270\321\217 \320\262 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\320\270.jpg" new file mode 100644 index 0000000..50f5986 Binary files /dev/null and "b/lesson26/\320\230\320\267\320\274\320\265\320\275\320\265\320\275\320\270\321\217 \320\262 \320\277\321\200\320\270\320\273\320\276\320\266\320\265\320\275\320\270\320\270.jpg" differ