-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
94 lines (93 loc) · 3.51 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
91
92
93
94
#! Groovy
pipeline {
agent { label 'pnl-builder' }
stages {
stage('Build_and_Test') {
steps {
script { echo "Building and testing branch: " + scm.branches[0].name }
sh 'cpanm --notest -L local --installdeps .'
sh 'cpanm --notest -L local Test::NoWarnings Plack Daemon::Control Starman'
sh 'prove -Ilocal/lib/perl5 --formatter=TAP::Formatter::JUnit --timer -wl t/ > testout.xml'
archiveArtifacts artifacts: 'local/**, lib/**, bin/**, environments/**, config.yml, views/**, public/**'
}
post {
changed {
junit 'testout.xml'
}
}
}
stage('MergeConfig') {
steps {
step([$class: 'WsCleanup'])
unarchive mapping: ['**': 'deploy/']
checkout([
$class: 'GitSCM',
branches: [[name: '*/main']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'configs'
]],
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: '4c42570e-2cb1-4450-a1db-f4d37d34b019',
url: 'ssh://[email protected]:9999/~/ztreet-configs'
]]
])
script {
echo "Testing '${scm.branches[0].name}' for main..."
if (scm.branches[0].name == 'main') {
sh 'cp configs/perl.nl/production.yml deploy/environments/'
}
else {
sh 'cp configs/perl.nl/pnl-test.yml deploy/environments/'
}
sh 'cp configs/perl.nl/announce_amsterdam_pm.yml deploy/environments/'
sh 'chmod +x deploy/local/bin/*'
}
archiveArtifacts artifacts: 'deploy/**'
}
}
stage('DeployPreview') {
when {
// branch 'preview'
expression {
echo "BRANCH_NAME is ${scm.branches[0].name}"
return scm.branches[0].name == "preview"
}
}
steps {
sh 'chmod +x deploy/local/bin/*'
sh 'chmod +x deploy/bin/*'
sshagent(['ssh-deploy']) {
sh '''
/usr/bin/deploy -av deploy/ pnl.fritz.box:/var/lib/www/perl.nl-preview
/usr/bin/restart-remote pnl.fritz.box perl.nl-preview
'''
}
}
}
stage('DeployProduction') {
when {
//branch 'main'
expression {
echo "BRANCH_NAME is ${scm.branches[0].name}"
return scm.branches[0].name == "main"
}
}
steps {
script {
def usrinput = input message: "Deploy or Abort ?", ok: "Deploy!"
}
sh 'chmod +x deploy/local/bin/*'
sh 'touch deploy/tsgateway'
sshagent(['ssh-deploy']) {
sh '''
/usr/bin/deploy -av deploy/ pnl.fritz.box:/var/lib/www/perl.nl-production
/usr/bin/restart-remote pnl.fritz.box perl.nl-production
'''
}
}
}
}
}