129 lines
4.1 KiB
Groovy
129 lines
4.1 KiB
Groovy
#!groovy
|
|
stage('Preparation') {
|
|
node('master') {
|
|
timeout(time: 30, unit: 'MINUTES') {
|
|
currentBuild.result = 'SUCCESS'
|
|
currentBuild.description = 'VNCProject signup for EKBO'
|
|
|
|
// clean workspace
|
|
deleteDir()
|
|
|
|
// http://stackoverflow.com/questions/38198878/jenkins-pipeline-build-github-pull-request#answer-38212467
|
|
checkout scm
|
|
|
|
sh('git log -1 > GIT_COMMIT_MESSAGE')
|
|
git_commit_message=readFile('GIT_COMMIT_MESSAGE')
|
|
|
|
sh('git show -1 > GIT_COMMIT_DIFF')
|
|
git_commit_diff=readFile('GIT_COMMIT_DIFF')
|
|
|
|
sh('git log -1 --format="%aN <%aE>" --reverse > GIT_COMMIT_AUTHOR')
|
|
git_commit_author=readFile('GIT_COMMIT_AUTHOR')
|
|
|
|
sh('git --no-pager log -1 --pretty=format:"%an" > GIT_COMMIT_AUTHOR_NAME')
|
|
git_commit_author_name=readFile('GIT_COMMIT_AUTHOR_NAME')
|
|
|
|
sh('git --no-pager log -1 --pretty=format:"%ae" > GIT_COMMIT_AUTHOR_EMAIL')
|
|
git_commit_author_email=readFile('GIT_COMMIT_AUTHOR_EMAIL')
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
stage('Build') {
|
|
node('vncportal') {
|
|
timeout(time: 30, unit: 'MINUTES') {
|
|
currentBuild.result = 'SUCCESS'
|
|
currentBuild.description = 'HIN API service'
|
|
|
|
// clean workspace
|
|
deleteDir()
|
|
|
|
// http://stackoverflow.com/questions/38198878/jenkins-pipeline-build-github-pull-request#answer-38212467
|
|
checkout scm
|
|
|
|
try {
|
|
sh 'yarn install'
|
|
sh 'tar cfz build.tar.gz * .??*'
|
|
stash includes: 'build.tar.gz', name: 'build'
|
|
|
|
} catch (BuildStageError) {
|
|
currentBuild.result = 'FAILURE'
|
|
sendNotification()
|
|
// stop execution
|
|
throw BuildStageError
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Packaging') {
|
|
if (currentBuild.result == 'SUCCESS') {
|
|
node('master') {
|
|
sh "echo 'Packaging'"
|
|
deleteDir()
|
|
checkout scm
|
|
sh "git fetch --tags"
|
|
unstash 'build'
|
|
sh "tar xvf build.tar.gz"
|
|
sh "makechangelog.uxf > debian/changelog"
|
|
sh "cat debian/changelog"
|
|
sh "mkdir src"
|
|
sh "sed -n 1p debian/changelog | grep -oP '\\((.*?)\\)' > src/version.txt"
|
|
sh "echo '####################################################'"
|
|
sh "cat src/version.txt"
|
|
sh "echo '####################################################'"
|
|
|
|
sh 'rm config/vnc-avatarservice.js'
|
|
sh 'cp -P conf.template/vnc-avatarservice.js config/vnc-avatarservice.js'
|
|
// yarn fails on node4 with kurento stuff
|
|
lock('debianbuild') {
|
|
sh "cd debian; debuild --check-dirname-level 0 --no-tgz-check --no-lintian -kjenkins@vnc.biz -p'gpg --no-tty --passphrase q3tx65wurstbrot'; cd .."
|
|
}
|
|
sh "mkdir -p ../pkgarchive/"
|
|
sh "scp ../*.deb repo@factorypackages.rz.vnc.biz:/srv/repo/apt/incoming/"
|
|
sh "ssh repo@factorypackages.rz.vnc.biz /srv/repo/bin/import-new-packages.sh"
|
|
|
|
// Import to GCP deb repository
|
|
sh "scp ../*.deb repo@34.89.202.54:/srv/repo/apt/incoming/"
|
|
sh "ssh repo@34.89.202.54 /srv/repo/bin/import-new-packages.sh"
|
|
|
|
sh "mv ../*.deb ../pkgarchive/"
|
|
sh "rm ../*.dsc"
|
|
sh "rm ../*amd64.build"
|
|
sh "rm ../*amd64.changes"
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Notification') {
|
|
node('master') {
|
|
sendNotification()
|
|
}
|
|
}
|
|
|
|
@NonCPS
|
|
def sendNotification() {
|
|
if (currentBuild.result == 'SUCCESS') {
|
|
// send to author only on successful build
|
|
// ${git_commit_author_email} is not available here
|
|
emailext (
|
|
to: 'stefan.saenger@vnc.biz',
|
|
attachmentsPattern: '**/testoutput/robot-console.txt',
|
|
subject: "${env.JOB_NAME} #${env.BUILD_NUMBER} [${currentBuild.result}]",
|
|
body: "Build URL: ${env.BUILD_URL}.\n\n Author: ${git_commit_author}\n\n Commit: ${git_commit_message}\n\nDiff: ${git_commit_diff}",
|
|
attachLog: false,
|
|
)
|
|
} else {
|
|
// send to team on failure
|
|
emailext (
|
|
to: 'stefan.saenger@vnc.biz',
|
|
attachmentsPattern: '**/testoutput/robot-console.txt',
|
|
subject: "${env.JOB_NAME} #${env.BUILD_NUMBER} [${currentBuild.result}] (${git_commit_author_name})",
|
|
body: "Build URL: ${env.BUILD_URL}.\n\n Author: ${git_commit_author}\n\n Commit: ${git_commit_message}\n\nDiff: ${git_commit_diff}",
|
|
attachLog: false,
|
|
)
|
|
}
|
|
}
|