48 lines
1.3 KiB
Groovy
48 lines
1.3 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
GIT_CREDENTIALS = 'gitea-creds'
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Checkout SCM') {
|
|
steps {
|
|
checkout scm
|
|
}
|
|
}
|
|
|
|
stage('Create file') {
|
|
steps {
|
|
sh '''
|
|
echo "Hello from Jenkins! Current time is $(date), run number ${BUILD_NUMBER}" > jenkis.txt
|
|
cat jenkis.txt
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Commit & Push') {
|
|
steps {
|
|
withCredentials([
|
|
usernamePassword(
|
|
credentialsId: env.GIT_CREDENTIALS,
|
|
usernameVariable: 'GIT_USER',
|
|
passwordVariable: 'GIT_PASS'
|
|
)
|
|
]) {
|
|
sh '''
|
|
git config user.email "jenkins@local"
|
|
git config user.name "Jenkins"
|
|
|
|
git add jenkis.txt
|
|
git commit -m "Jenkins: update jenkis.txt for run ${BUILD_NUMBER}" || echo "Nothing to commit"
|
|
|
|
git push https://$GIT_USER:$GIT_PASS@gitea.dev.bodnarescu.ro/s_zsolt/test_git.git HEAD:main
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|