Jenkins file update

This commit is contained in:
2025-10-17 12:48:22 +02:00
parent 53392c338a
commit d8e7cec0ab

34
Jenkinsfile vendored
View File

@@ -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
'''
}
}
}
}
}
}