-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
67 lines (66 loc) · 2.01 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pipeline {
agent any
stages {
stage('Test Config') {
agent {
docker {
image 'docker_hass_image'
args '-u 0'
}
}
stages{
stage('Deploy key') {
steps{
sh '''mkdir -p /home/homeassistant/.ssh
cd /home/homeassistant/.ssh
touch id_rsa'''
}
}
stage('Copy secrets') {
when {
not { branch 'secrets' }
}
steps {
sh '''mv travis_secrets.yaml secrets.yaml'''
}
}
stage('Test') {
steps {
sh '''hass --script check_config -c .'''
}
}
}
}
stage('Deployment') {
when { branch 'secrets' }
steps {
sshagent(['d6f00138-0986-4c78-868b-c92b7a9383d7']) {
sh """ssh [email protected] "cd Home-AssistantConf; git pull -r;
sudo systemctl restart [email protected];
sudo find . -type f -exec chgrp homeassistant {} \\;
sudo find . -type f -exec chmod 0664 {} \\;" """
}
}
}
}
post {
always {
echo 'One way or another, I have finished'
deleteDir() /* clean up our workspace */
}
success {
slackSend color: 'good',
message: "The pipeline ${currentBuild.fullDisplayName} completed successfully. Hass configuration is updated"
}
unstable {
echo 'I am unstable :/'
}
failure {
slackSend color: 'warning',
message: "This configuration is not working"
}
changed {
echo 'Things were different before...'
}
}
}