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