Add JenkinsFile
This commit is contained in:
53
JenkinsFile
Normal file
53
JenkinsFile
Normal file
@@ -0,0 +1,53 @@
|
||||
// Webhook trigger instellen via Jenkinsfile
|
||||
properties([
|
||||
pipelineTriggers([
|
||||
[$class: 'GenericTrigger',
|
||||
genericVariables: [
|
||||
[key: 'ref', value: '$.ref'] // haalt branch uit webhook payload
|
||||
],
|
||||
causeString: 'Triggered by Gitea push',
|
||||
token: 'deploy-ben', // token moet overeenkomen met Gitea webhook
|
||||
printContributedVariables: true,
|
||||
printPostContent: true,
|
||||
regexpFilterExpression: 'refs/heads/main', // alleen main branch
|
||||
regexpFilterText: '$ref'
|
||||
]
|
||||
])
|
||||
])
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
script {
|
||||
checkout([$class: 'GitSCM',
|
||||
branches: [[name: "${params.ref ?: 'refs/heads/main'}"]],
|
||||
userRemoteConfigs: [[
|
||||
url: 'https://git.de-roo.org/ben/ben.de-roo.org.git',
|
||||
credentialsId: 'Gitea-PAT-Ben'
|
||||
]]
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to web14') {
|
||||
steps {
|
||||
script {
|
||||
sshagent(credentials: ['ben.de-roo.org']) {
|
||||
sh '''
|
||||
rsync -avz --delete \
|
||||
--exclude .git \
|
||||
--exclude Jenkinsfile \
|
||||
-e "ssh -o StrictHostKeyChecking=no" \
|
||||
./ www-data@web14:/var/www/html/
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user