Skip to content

Commit e378016

Browse files
committed
Jenkins setup
1 parent c50cc8c commit e378016

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

jenkins/Jenkinsfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def remote = [:]
2+
remote.name = 'remote'
3+
remote.host = env.DEPLOY_HOST
4+
remote.user = env.DEPLOY_USER
5+
remote.identityFile = '/var/lib/jenkins/.ssh/id_rsa'
6+
remote.knownHosts = '/var/lib/jenkins/.ssh/known_hosts'
7+
remote.allowAnyHosts = true
8+
remote.retryCount = 3
9+
remote.retryWaitSec = 3
10+
logLevel = 'FINER'
11+
12+
pipeline {
13+
agent any
14+
stages {
15+
stage('Build') {
16+
steps {
17+
sh './jenkins/build.sh'
18+
//stash includes: 'target/', name: 'target'
19+
}
20+
}
21+
stage('Deploy') {
22+
steps {
23+
//unstash 'target'
24+
sshCommand remote: remote, command: 'rm -rf mar/target mar/deploy.sh'
25+
sshPut remote: remote, from: 'target', into: 'mar'
26+
sshPut remote: remote, from: 'jenkins/deploy.sh', into: 'mar/deploy.sh'
27+
sshCommand remote: remote, command: 'chmod +x mar/deploy.sh && ./mar/deploy.sh'
28+
}
29+
}
30+
}
31+
}
32+

jenkins/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
mvn package

jenkins/deploy.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
export MARROOT="mar"
4+
5+
screen -S mar -X quit
6+
echo "Starting MAR"
7+
8+
cp ${MARROOT}/marConfig.properties ${MARROOT}/target/config.properties
9+
cp -r ${MARROOT}/marCerts/ ${MARROOT}/target/certificates
10+
11+
screen -S mar -d -m bash -c "cd ${MARROOT}/target && java -jar server-*.jar"
12+
sleep 1
13+
screen -list

0 commit comments

Comments
 (0)