Skip to content

Commit

Permalink
Jenkins setup
Browse files Browse the repository at this point in the history
  • Loading branch information
simon987 committed Apr 3, 2019
1 parent c50cc8c commit e378016
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
32 changes: 32 additions & 0 deletions jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def remote = [:]
remote.name = 'remote'
remote.host = env.DEPLOY_HOST
remote.user = env.DEPLOY_USER
remote.identityFile = '/var/lib/jenkins/.ssh/id_rsa'
remote.knownHosts = '/var/lib/jenkins/.ssh/known_hosts'
remote.allowAnyHosts = true
remote.retryCount = 3
remote.retryWaitSec = 3
logLevel = 'FINER'

pipeline {
agent any
stages {
stage('Build') {
steps {
sh './jenkins/build.sh'
//stash includes: 'target/', name: 'target'
}
}
stage('Deploy') {
steps {
//unstash 'target'
sshCommand remote: remote, command: 'rm -rf mar/target mar/deploy.sh'
sshPut remote: remote, from: 'target', into: 'mar'
sshPut remote: remote, from: 'jenkins/deploy.sh', into: 'mar/deploy.sh'
sshCommand remote: remote, command: 'chmod +x mar/deploy.sh && ./mar/deploy.sh'
}
}
}
}

3 changes: 3 additions & 0 deletions jenkins/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

mvn package
13 changes: 13 additions & 0 deletions jenkins/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

export MARROOT="mar"

screen -S mar -X quit
echo "Starting MAR"

cp ${MARROOT}/marConfig.properties ${MARROOT}/target/config.properties
cp -r ${MARROOT}/marCerts/ ${MARROOT}/target/certificates

screen -S mar -d -m bash -c "cd ${MARROOT}/target && java -jar server-*.jar"
sleep 1
screen -list

0 comments on commit e378016

Please sign in to comment.