forked from spf-tools/spf-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
90 lines (75 loc) · 2.4 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
This Jenkinsfile will run the steps required to update route53 with the right
SPF records.
It will run on a regular basis based on the cron triggers below.
In order to modify the spf records, visit the Terraform route53 configuration
which is currently here: https://github.com/mention-me/Terraform/blob/master/Global/route53/mention-me.com.tf
And to add/modify domains, adjust the value of spf-orig.mention-me.com
*/
pipeline {
agent { label 'master' }
triggers {
cron('H */2 * * *')
}
stages {
stage('begin') {
steps {
sh '''
cat > ~/.spf-toolsrc <<EOF
DOMAIN=mention-me.com
ORIG_SPF=spf-orig.mention-me.com
# Salesforce uses a macro for its DNS record, so we can't despf it.
DESPF_SKIP_DOMAINS=_spf.salesforce.com
DNS_TIMEOUT=5
DNS_SERVER=
EOF
'''
}
}
stage('update') {
steps {
// The ZZLU8Z239WBCK is the hosted zone for route53.
sh './despf.sh | ./simplify.sh | ./mkblocks.sh | ./route53.sh -a "atlassian-domain-verification=kX3daeWIlwrB5fHA9nHG1RjKnattCP7f64x7JkiJpg0KFE69RRIMb/MtwEivRNP2" -a "google-site-verification=d2qINZJBc4QLzUyRa4S5JUM45TJF15jbHauUZpCXK9o" -a "apple-domain-verification=dAgmnWhoE9L4z1iE" -a "reachdesk-verification=zbXcLZQkiReWKyypk8G4ZH7XzzyAn6wrWNIkAZ7d3Q50a98MJKu8hLk4ePt8T1CK" ZZLU8Z239WBCK'
}
}
stage('compare') {
steps {
// compare.sh will fail if the DNS records are different
sh '''
./compare.sh
'''
}
}
}
post {
always {
sendNotifications currentBuild.result
}
}
}
/**
* Send notifications based on build status string
*
* Borrowed from: https://jenkins.io/blog/2017/02/15/declarative-notifications/
*/
def sendNotifications(String buildStatus = 'STARTED') {
def branch = "${env.BRANCH_NAME}"
if (! (branch ==~ /master|development|release-.*/)) {
return
}
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
// We only care about failure. Skip anything else.
if (buildStatus == 'STARTED' || buildStatus == 'NOT_BUILT' || buildStatus == 'SUCCESS') {
return
}
color = 'RED'
colorCode = '#FF0000'
// Send notifications
slackSend (channel: '#engineering-bots', color: colorCode, message: summary)
}