From d8e7cec0ab5d692ddb1c98ae25361954b73283e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20R=C5=AF=C5=BEi=C4=8Dka?= Date: Fri, 17 Oct 2025 12:48:22 +0200 Subject: [PATCH] Jenkins file update --- Jenkinsfile | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 479058f..574357f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,20 +1,40 @@ pipeline { agent any + environment { + GIT_CREDENTIALS = 'jenkins-gitea-karel-token' // the ID of your Jenkins Gitea credentials + } stages { - stage('Build') { + stage('Checkout') { steps { - echo 'Building...' + // Clone repo + git branch: 'main', credentialsId: env.GIT_CREDENTIALS, url: 'https://git.karel.one/karel/test.git' } } - stage('Test') { + stage('Modify File') { steps { - echo 'Testing...' + script { + // Append a line to test.txt (create if it doesn't exist) + def file = 'test.txt' + if (!fileExists(file)) { + writeFile file: file, text: 'This is the first line\n' + } else { + writeFile file: file, text: readFile(file) + "Updated by Jenkins at ${new Date()}\n" + } + } } } - stage('Deploy') { + stage('Commit & Push') { steps { - echo 'Deploying...' + script { + sh ''' + git config user.name "jenkins" + git config user.email "jenkins@example.com" + git add test.txt + git commit -m "Update test.txt from Jenkins" + git push origin main + ''' + } } } } -} +} \ No newline at end of file