-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
41 lines (35 loc) · 1.86 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
node('master') {
properties([buildDiscarder(logRotator(numToKeepStr: '5')), [$class: 'GithubProjectProperty', projectUrlStr: 'https://github.com/Tibi02/hannablog'], pipelineTriggers([githubPush()])])
ws('/disk/docker/hannablog') {
stage('Git checkout') {
ansiColor('xterm') {
git = checkout([$class: 'GitSCM', branches: [[name: '*/master']], browser: [$class: 'GithubWeb', repoUrl: 'https://github.com/Tibi02/hannablog'], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'MessageExclusion', excludedMessage: 'skip ci'], [$class: 'LocalBranch', localBranch: 'master']], userRemoteConfigs: [[credentialsId: 'oktibor-ci', url: '[email protected]:Tibi02/hannablog.git']]])
sh('chown -R www-data:www-data .')
}
}
stage('Docker pull') {
ansiColor('xterm') {
sh('docker-compose pull')
}
}
stage('Recreate container') {
ansiColor('xterm') {
withCredentials([usernamePassword(credentialsId: 'mysql', passwordVariable: 'MYSQL_PASSWORD', usernameVariable: 'MYSQL_USER')]) {
sh('docker-compose -f docker-compose.yml up -d --force-recreate')
}
}
}
}
}
def setGithubStatus(status, commitId) {
githubNotify(account: 'Tibi02', repo: 'hannablog', context: 'Deploy', sha: commitId, credentialsId: 'oktibor-ci-github', status: status)
}
void setBuildStatus(String message, String status) {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/Tibi02/hannablog"],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/deploy"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: status]] ]
]);
}