cleanup jenkinsfile and prepare for builds on new linux slaves

This commit is contained in:
Jakub Sokołowski 2018-08-06 11:12:32 -04:00
parent ef2d0fd4d0
commit 8eaed87a96
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 172 additions and 133 deletions

View File

@ -7,9 +7,25 @@ properties([
)) ))
]) ])
env.LANG="en_US.UTF-8" env.LANG = 'en_US.UTF-8'
env.LANGUAGE="en_US.UTF-8" env.LANGUAGE = 'en_US.UTF-8'
env.LC_ALL="en_US.UTF-8" env.LC_ALL = 'en_US.UTF-8'
apkUrl = ''
ipaUrl = ''
testPassed = true
scriptOutput = ''
packageFolder = './StatusImPackage'
external_modules_dir = [
'node_modules/react-native-i18n/desktop',
'node_modules/react-native-config/desktop',
'node_modules/react-native-fs/desktop',
'node_modules/react-native-http-bridge/desktop',
'node_modules/react-native-webview-bridge/desktop',
'node_modules/react-native-keychain/desktop',
'node_modules/react-native-securerandom/desktop',
'modules/react-native-status/desktop',
]
def installJSDeps() { def installJSDeps() {
def attempt = 1 def attempt = 1
@ -20,7 +36,7 @@ def installJSDeps() {
while (!installed && attempt <= maxAttempts) { while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps" println "#${attempt} attempt to install npm deps"
sh 'scripts/prepare-for-platform.sh desktop' sh 'scripts/prepare-for-platform.sh desktop'
sh 'npm install --verbose' sh 'npm install'
installed = fileExists('node_modules/web3/index.js') installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1 attemp = attempt + 1
} }
@ -35,170 +51,193 @@ def doGitRebase() {
} }
} }
def cleanupBuild(packageFolder) { def cleanupBuild() {
sh 'rm -rf node_modules' sh 'rm -rf node_modules'
sh ( 'rm -rf ' + packageFolder ) sh "rm -rf ${packageFolder}"
sh 'rm -rf desktop/modules' sh 'rm -rf desktop/modules'
sh 'rm -rf desktop/node_modules' sh 'rm -rf desktop/node_modules'
} }
parallel ( def cleanupAndDeps() {
"MacOS parallel build stream" : { cleanupBuild()
timeout(90) {
node ('macos1') {
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def branch;
def scriptOutput = ''
def packageFolder = './StatusImPackage'
def scriptPath = sh(script: 'pwd -P', returnStdout: true).trim()
load "$HOME/env.groovy"
try {
stage('Git & Dependencies') {
slackSend channel: '#jenkins-desktop', color: 'good', message: BRANCH_NAME + '(' + env.CHANGE_BRANCH + ') MacOS build started. ' + env.BUILD_URL
sh ('echo ' + scriptPath)
checkout scm
doGitRebase()
cleanupBuild(packageFolder)
sh 'cp .env.jenkins .env' sh 'cp .env.jenkins .env'
sh 'lein deps' sh 'lein deps'
installJSDeps() installJSDeps()
} }
stage('Build ClojureScript') { def slackNotify(message, color = 'good') {
slackSend(
color: color,
channel: '#jenkins-desktop',
message: "${BRANCH_NAME}(${env.CHANGE_BRANCH}) ${message} ${env.BUILD_URL}"
)
}
def buildClojureScript() {
sh 'rm -f index.desktop.js' sh 'rm -f index.desktop.js'
sh 'lein prod-build-desktop' sh 'lein prod-build-desktop'
sh "mkdir ${packageFolder}"
sh """
react-native bundle \\
--entry-file index.desktop.js \\
--dev false --platform desktop \\
--bundle-output ${packageFolder}/StatusIm.jsbundle \\
--assets-dest ${packageFolder}/assets
"""
}
sh ( 'mkdir ' + packageFolder ) parallel(
sh ( 'react-native bundle --entry-file index.desktop.js --bundle-output ' + packageFolder + '/StatusIm.jsbundle --dev false --platform desktop --assets-dest ' + packageFolder + '/assets' ) 'MacOS build': {
timeout(90) {
node('macos1') {
load "$HOME/env.groovy"
try {
stage('Git & Deps') {
slackNotify('MacOS build started.')
checkout scm
doGitRebase()
cleanupAndDeps()
}
stage('Build ClojureScript') {
buildClojureScript()
} }
stage('Build MacOS binaries') { stage('Build MacOS binaries') {
sh 'cd desktop && rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile' /* add path for QT installation binaries */
sh 'export PATH=/Users/administrator/qt/5.9.1/clang_64/bin:$PATH && cd desktop && cmake -DCMAKE_BUILD_TYPE=Release -DEXTERNAL_MODULES_DIR="node_modules/react-native-i18n/desktop;node_modules/react-native-config/desktop;node_modules/react-native-fs/desktop;node_modules/react-native-http-bridge/desktop;node_modules/react-native-webview-bridge/desktop;node_modules/react-native-keychain/desktop;node_modules/react-native-securerandom/desktop;modules/react-native-status/desktop"\ env.PATH = "/Users/administrator/qt/5.9.1/clang_64/bin:${env.PATH}"
-DJS_BUNDLE_PATH="' + scriptPath + '/' + packageFolder + '/StatusIm.jsbundle" -DCMAKE_CXX_FLAGS:="-DBUILD_FOR_BUNDLE=1" . && make' dir('desktop') {
sh 'rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile'
sh """
cmake -Wno-dev \\
-DCMAKE_BUILD_TYPE=Release \\
-DEXTERNAL_MODULES_DIR='${external_modules_dir.join(";")}' \\
-DJS_BUNDLE_PATH='${workspace}/${packageFolder}/StatusIm.jsbundle' \\
-DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1'
"""
sh 'make'
}
} }
stage('Prepare and create MacOS Bundle') { stage('Create MacOS Bundle') {
sh ('cd ' + packageFolder + ' && git clone https://github.com/vkjr/StatusAppFiles.git && unzip StatusAppFiles/StatusIm.app.zip') dir(packageFolder) {
sh ('cp -r ' + packageFolder + '/assets/share/assets ' + packageFolder +'/StatusIm.app/Contents/MacOs') sh 'git clone https://github.com/vkjr/StatusAppFiles.git
sh ('chmod +x ' + packageFolder + '/StatusIm.app/Contents/MacOs/ubuntu-server') sh 'unzip StatusAppFiles/StatusIm.app.zip'
sh ('cp ./desktop/bin/StatusIm ' + packageFolder +'/StatusIm.app/Contents/MacOs') sh 'cp -r assets/share/assets StatusIm.app/Contents/MacOs'
sh 'chmod +x StatusIm.app/Contents/MacOs/ubuntu-server'
sh ('export PATH=/Users/administrator/qt/5.9.1/clang_64/bin:$PATH && cd ' + packageFolder + ' && macdeployqt StatusIm.app -verbose=1 -dmg -qmldir="' + scriptPath + '/node_modules/react-native/ReactQt/runtime/src/qml/"') sh 'cp ../desktop/bin/StatusIm StatusIm.app/Contents/MacOs'
sh """
sh 'rm -rf StatusAppFiles' macdeployqt StatusIm.app -verbose=1 -dmg \\
-qmldir='${workspace}/node_modules/react-native/ReactQt/runtime/src/qml/'
"""
sh 'rm -f StatusAppFiles'
}
} }
stage('Archive built artifact') { stage('Archive Artifact') {
archiveArtifacts "StatusImPackage/*.dmg" archiveArtifacts 'StatusImPackage/*.dmg'
} }
cleanupBuild(packageFolder) slackNotify('MacOS build finished successfully.')
slackSend channel: '#jenkins-desktop', color: 'good', message: BRANCH_NAME + '(' + env.CHANGE_BRANCH + ') MacOS build finished successfully. ' + env.BUILD_URL
} catch (e) { } catch (e) {
cleanupBuild(packageFolder) slackNotify('Failed to build on MacOS.', color: 'bad')
slackSend channel: '#jenkins-desktop', color: 'bad', message: BRANCH_NAME + ' failed to build on MacOS. ' + env.BUILD_URL
throw e throw e
} finally {
cleanupBuild()
} }
} }
} }
}, },
"Linux parallel build stream" : { 'Linux build': {
timeout(90) { timeout(90) {
node ('linux1') { node ('linux-01') {
def apkUrl = '' def qt_bin = '/opt/qt59/bin'
def ipaUrl = ''
def testPassed = true
def branch;
def scriptOutput = ''
def packageFolder = './StatusImPackage'
def scriptPath = sh(script: 'pwd -P', returnStdout: true).trim()
sh ('echo ' + scriptPath)
try { try {
stage('Git & Deps') {
stage('Git & Dependencies') { slackNotify('Linux build started.')
slackSend channel: '#jenkins-desktop', color: 'good', message: BRANCH_NAME + '(' + env.CHANGE_BRANCH + ') Linux build started. ' + env.BUILD_URL
sh ('echo ' + scriptPath)
checkout scm checkout scm
doGitRebase() doGitRebase()
cleanupAndDeps()
cleanupBuild(packageFolder)
sh 'cp .env.jenkins .env'
sh 'lein deps'
installJSDeps()
} }
stage('Build ClojureScript') { stage('Build ClojureScript') {
sh 'rm -f index.desktop.js' buildClojureScript()
sh 'lein prod-build-desktop'
sh ( 'mkdir ' + packageFolder )
sh ( 'react-native bundle --entry-file index.desktop.js --bundle-output ' + packageFolder + '/StatusIm.jsbundle --dev false --platform desktop --assets-dest ' + packageFolder + '/assets' )
} }
stage('Build Linux binaries') { stage('Build Linux binaries') {
sh 'cd desktop && rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile' /* add path for QT installation binaries */
sh 'export PATH=/home/maxr/Qt5.9.1/5.9.1/gcc_64/bin:/usr/local/go/bin:$PATH && cd desktop && cmake -DCMAKE_BUILD_TYPE=Release -DEXTERNAL_MODULES_DIR="node_modules/react-native-i18n/desktop;node_modules/react-native-config/desktop;node_modules/react-native-fs/desktop;node_modules/react-native-http-bridge/desktop;node_modules/react-native-webview-bridge/desktop;node_modules/react-native-keychain/desktop;node_modules/react-native-securerandom/desktop;modules/react-native-status/desktop"\ env.PATH = "${qt_bin}:${env.PATH}"
-DJS_BUNDLE_PATH="' + scriptPath + '/' + packageFolder + '/StatusIm.jsbundle" -DCMAKE_CXX_FLAGS:="-DBUILD_FOR_BUNDLE=1" . && make' dir('desktop') {
sh 'rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile'
sh """
cmake -Wno-dev \\
-DCMAKE_BUILD_TYPE=Release \\
-DEXTERNAL_MODULES_DIR='${external_modules_dir.join(";")}' \\
-DJS_BUNDLE_PATH='${workspace}/${packageFolder}/StatusIm.jsbundle' \\
-DCMAKE_CXX_FLAGS:='-DBUILD_FOR_BUNDLE=1'
"""
sh 'make'
}
} }
stage('Prepare and create Linux AppImage') { stage('Create Linux AppImage') {
sh ('rm -rf ' + packageFolder + '/StatusImAppImage') dir(packageFolder) {
sh ('cd ' + packageFolder + ' && cp /home/maxr/qttools/StatusImAppImage.zip ./ && unzip ./StatusImAppImage.zip') sh 'rm -rf StatusImAppImage'
/* TODO this needs to be fixed: status-react/issues/5378 */
sh ('rm -rf ' + packageFolder + '/AppDir && mkdir ' + packageFolder + '/AppDir') sh 'cp /opt/StatusImAppImage.zip ./'
sh ('cp -r ./deployment/linux/usr ' + packageFolder + '/AppDir') sh 'unzip ./StatusImAppImage.zip'
sh ('cp ./deployment/linux/.env ' + packageFolder + '/AppDir') sh 'rm -rf AppDir'
sh ('cp ./desktop/bin/StatusIm ' + packageFolder+ '/AppDir/usr/bin') sh 'mkdir AppDir'
}
sh ('cp -f /home/maxr/qttools/linuxdeployqt-continuous-x86_64.AppImage ./') sh "cp -r ./deployment/linux/usr ${packageFolder}/AppDir"
sh ('chmod a+x ./linuxdeployqt-continuous-x86_64.AppImage') sh "cp ./deployment/linux/.env ${packageFolder}/AppDir"
sh "cp ./desktop/bin/StatusIm ${packageFolder}/AppDir/usr/bin"
sh 'wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage'
sh 'chmod a+x ./linuxdeployqt-continuous-x86_64.AppImage'
sh 'rm -f Application-x86_64.AppImage' sh 'rm -f Application-x86_64.AppImage'
sh 'rm -f StatusIm-x86_64.AppImage' sh 'rm -f StatusIm-x86_64.AppImage'
sh 'ldd ' + packageFolder+ '/AppDir/usr/bin/StatusIm' sh "ldd ${packageFolder}/AppDir/usr/bin/StatusIm"
sh ('export PATH=/home/maxr/Qt5.9.1/5.9.1/gcc_64/bin:/usr/local/go/bin:$PATH && ./linuxdeployqt-continuous-x86_64.AppImage ' + packageFolder+ '/AppDir/usr/share/applications/StatusIm.desktop -verbose=3 -always-overwrite -no-strip -no-translations -bundle-non-qt-libs -qmake=/home/maxr/Qt5.9.1/5.9.1/gcc_64/bin/qmake -extra-plugins=imageformats/libqsvg.so -qmldir="' + scriptPath + '/node_modules/react-native"') sh """
sh 'ldd ' + packageFolder+ '/AppDir/usr/bin/StatusIm' ./linuxdeployqt-continuous-x86_64.AppImage \\
${packageFolder}/AppDir/usr/share/applications/StatusIm.desktop \\
sh ('cp -r ' + packageFolder + '/assets/share/assets ' + packageFolder +'/AppDir/usr/bin') -verbose=3 -always-overwrite -no-strip \\
sh ('cp -rf ' + packageFolder + '/StatusImAppImage/* ' + packageFolder +'/AppDir/usr/bin') -no-translations -bundle-non-qt-libs \\
sh ('rm -f ' + packageFolder +'/AppDir/usr/bin/StatusIm.AppImage') -qmake=${qt_bin}/qmake \\
-extra-plugins=imageformats/libqsvg.so \\
sh ('export PATH=/home/maxr/Qt5.9.1/5.9.1/gcc_64/bin:/usr/local/go/bin:$PATH && ./linuxdeployqt-continuous-x86_64.AppImage ' + packageFolder+ '/AppDir/usr/share/applications/StatusIm.desktop -verbose=3 -appimage -qmake=/home/maxr/Qt5.9.1/5.9.1/gcc_64/bin/qmake') -qmldir='${workspace}/node_modules/react-native'
sh 'ldd ' + packageFolder+ '/AppDir/usr/bin/StatusIm' """
dir(packageFolder) {
sh ('rm -rf ' + packageFolder +'/StatusIm.AppImage') sh 'ldd AppDir/usr/bin/StatusIm'
sh ('cp -f ./StatusIm-x86_64.AppImage ' + packageFolder + '/StatusIm.AppImage') sh 'cp -r assets/share/assets AppDir/usr/bin'
sh 'cp -rf StatusImAppImage/* AppDir/usr/bin'
sh 'rm -f AppDir/usr/bin/StatusIm.AppImage'
}
sh """
./linuxdeployqt-continuous-x86_64.AppImage \\
${packageFolder}/AppDir/usr/share/applications/StatusIm.desktop \\
-verbose=3 -appimage -qmake=${qt_bin}/qmake
"""
dir(packageFolder) {
sh 'ldd AppDir/usr/bin/StatusIm'
sh 'rm -rf StatusIm.AppImage'
sh 'cp -f ../StatusIm-x86_64.AppImage StatusIm.AppImage'
}
} }
stage('Archive built artifact') { stage('Archive Artifact') {
archiveArtifacts "StatusImPackage/*.AppImage" archiveArtifacts 'StatusImPackage/*.AppImage'
} }
cleanupBuild(packageFolder) slackNotify('Linux build finished successfully.')
slackSend channel: '#jenkins-desktop', color: 'good', message: BRANCH_NAME + '(' + env.CHANGE_BRANCH + ') Linux build finished successfully. ' + env.BUILD_URL
} catch (e) { } catch (e) {
cleanupBuild(packageFolder) slackNotify('Failed to build on Linux.', color: 'bad')
slackSend channel: '#jenkins-desktop', color: 'bad', message: BRANCH_NAME + ' failed to build on Linux. ' + env.BUILD_URL
throw e throw e
} finally {
cleanupBuild()
} }
} }
} }