diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..49eef215f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +pipeline { + agent any + environment { + TELEGRAM_TOKEN = credentials('telegram_token') + TELEGRAM_CHAT_ID = credentials('telegram_chat_id') + } + tools { + maven 'Maven' + } + stages { + stage('Pre-build') { + steps { + echo 'Preparing to build...' + sh 'curl -s -X POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage -d chat_id=$TELEGRAM_CHAT_ID -d text="Start pipline"' + } + } + stage('Build') { + steps { + echo 'Building...' + sh 'mvn -f initial/pom.xml clean install' + } + } + stage('Post-build'){ + steps { + archiveArtifacts artifacts: '**/*.jar' + } + } + } + post { + success { + sh 'curl -s -X POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage -d chat_id=$TELEGRAM_CHAT_ID -d text="Pipline success"' + } + failure { + sh 'curl -s -X POST https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage -d chat_id=$TELEGRAM_CHAT_ID -d text="Pipline failed"' + } + } +} diff --git a/Lecture3/README.md b/Lecture3/README.md new file mode 100644 index 000000000..4f3ce28ab --- /dev/null +++ b/Lecture3/README.md @@ -0,0 +1,29 @@ +## Jenkins freestyle job +1. Create a new Jenkins freestyle job named "Simple Freestyle Job".![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.47.23.png) +2. Add my git repo in Source Code Management ![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.48.30.png) +3. Setup some environment variables for test ![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.49.02.png) +4. Configured Build steps: + - Install maven plugins + - Add goal "clean install" + - ![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.49.31.png) +5. Configure Post-build actions: + - Add "Archive the artifacts" and specify the path to the build artifacts `**/*.jar` to archive all .jar files + - ![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.49.48.png) + +## Jenkins pipline +1. Create a new Jenkins pipeline job named "Simple First Pipeline". +2. Add my git repo in Source Code Management +3. Setup pipline defenition for all git branches and also added my test branch with Jenkins file ![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.44.53.png) +4. Create separate branch with Jenkinsfile +5. Configure Jenkinsfile with: + - Add Maven tolls to build project with mvn clean install + - Add telegram secrets in Jenkins credentials ![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.46.10.png) +6. Added 'Pre-build', 'Build', 'Post-build' stage +7. Pre-build stage: + - Added telegram notification for start build +8. Build stage: + - Added mvn clean install with path to pom.xml file +9. Post-build stage: + - Added 'Archive the artifacts' and specify the path to the build artifacts `**/*. +10. Post: + - Added telegram notification for build success or failure ![Alt text](Lecture3/images/Screenshot 2025-12-09 at 15.33.00.png) diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.33.00.png b/Lecture3/images/Screenshot 2025-12-09 at 15.33.00.png new file mode 100644 index 000000000..0a51cc1cc Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.33.00.png differ diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.44.53.png b/Lecture3/images/Screenshot 2025-12-09 at 15.44.53.png new file mode 100644 index 000000000..c06024aba Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.44.53.png differ diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.46.10.png b/Lecture3/images/Screenshot 2025-12-09 at 15.46.10.png new file mode 100644 index 000000000..97b1508ed Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.46.10.png differ diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.47.23.png b/Lecture3/images/Screenshot 2025-12-09 at 15.47.23.png new file mode 100644 index 000000000..c2db7eb83 Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.47.23.png differ diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.48.30.png b/Lecture3/images/Screenshot 2025-12-09 at 15.48.30.png new file mode 100644 index 000000000..daba27cd1 Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.48.30.png differ diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.49.02.png b/Lecture3/images/Screenshot 2025-12-09 at 15.49.02.png new file mode 100644 index 000000000..17f223b5d Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.49.02.png differ diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.49.31.png b/Lecture3/images/Screenshot 2025-12-09 at 15.49.31.png new file mode 100644 index 000000000..847ce86c9 Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.49.31.png differ diff --git a/Lecture3/images/Screenshot 2025-12-09 at 15.49.48.png b/Lecture3/images/Screenshot 2025-12-09 at 15.49.48.png new file mode 100644 index 000000000..c297eb84a Binary files /dev/null and b/Lecture3/images/Screenshot 2025-12-09 at 15.49.48.png differ