2018-07-24 18:41:07 +00:00
|
|
|
properties([
|
2018-08-06 15:12:32 +00:00
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '2',
|
|
|
|
daysToKeepStr: '3',
|
|
|
|
artifactNumToKeepStr: '2',
|
|
|
|
artifactDaysToKeepStr: '3'
|
|
|
|
))
|
2018-07-24 18:41:07 +00:00
|
|
|
])
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
env.LANG = 'en_US.UTF-8'
|
|
|
|
env.LANGUAGE = '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',
|
|
|
|
]
|
2018-07-23 15:21:31 +00:00
|
|
|
|
|
|
|
def installJSDeps() {
|
2018-08-06 15:12:32 +00:00
|
|
|
def attempt = 1
|
|
|
|
def maxAttempts = 10
|
|
|
|
def installed = false
|
|
|
|
sh 'node -v'
|
|
|
|
sh 'npm -v'
|
|
|
|
while (!installed && attempt <= maxAttempts) {
|
|
|
|
println "#${attempt} attempt to install npm deps"
|
|
|
|
sh 'scripts/prepare-for-platform.sh desktop'
|
|
|
|
sh 'npm install'
|
|
|
|
installed = fileExists('node_modules/web3/index.js')
|
|
|
|
attemp = attempt + 1
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def doGitRebase() {
|
|
|
|
try {
|
|
|
|
sh 'git rebase origin/develop'
|
|
|
|
} catch (e) {
|
|
|
|
sh 'git rebase --abort'
|
|
|
|
throw e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
def cleanupBuild() {
|
2018-07-23 15:21:31 +00:00
|
|
|
sh 'rm -rf node_modules'
|
2018-08-06 15:12:32 +00:00
|
|
|
sh "rm -rf ${packageFolder}"
|
2018-07-23 15:21:31 +00:00
|
|
|
sh 'rm -rf desktop/modules'
|
|
|
|
sh 'rm -rf desktop/node_modules'
|
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
def cleanupAndDeps() {
|
|
|
|
cleanupBuild()
|
|
|
|
sh 'cp .env.jenkins .env'
|
|
|
|
sh 'lein deps'
|
|
|
|
installJSDeps()
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
def slackNotify(message, color = 'good') {
|
|
|
|
slackSend(
|
|
|
|
color: color,
|
|
|
|
channel: '#jenkins-desktop',
|
|
|
|
message: "${BRANCH_NAME}(${env.CHANGE_BRANCH}) ${message} ${env.BUILD_URL}"
|
|
|
|
)
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
def buildClojureScript() {
|
|
|
|
sh 'rm -f index.desktop.js'
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
parallel(
|
|
|
|
'MacOS build': {
|
|
|
|
timeout(90) {
|
|
|
|
node('macos1') {
|
|
|
|
load "$HOME/env.groovy"
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
try {
|
|
|
|
stage('Git & Deps') {
|
|
|
|
slackNotify('MacOS build started.')
|
2018-07-23 15:21:31 +00:00
|
|
|
checkout scm
|
|
|
|
doGitRebase()
|
2018-08-06 15:12:32 +00:00
|
|
|
cleanupAndDeps()
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build ClojureScript') {
|
2018-08-06 15:12:32 +00:00
|
|
|
buildClojureScript()
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build MacOS binaries') {
|
2018-08-06 15:12:32 +00:00
|
|
|
/* add path for QT installation binaries */
|
|
|
|
env.PATH = "/Users/administrator/qt/5.9.1/clang_64/bin:${env.PATH}"
|
|
|
|
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'
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
stage('Create MacOS Bundle') {
|
|
|
|
dir(packageFolder) {
|
2018-08-07 14:54:37 +00:00
|
|
|
sh 'git clone https://github.com/vkjr/StatusAppFiles.git'
|
2018-08-06 15:12:32 +00:00
|
|
|
sh 'unzip StatusAppFiles/StatusIm.app.zip'
|
|
|
|
sh 'cp -r assets/share/assets StatusIm.app/Contents/MacOs'
|
|
|
|
sh 'chmod +x StatusIm.app/Contents/MacOs/ubuntu-server'
|
|
|
|
sh 'cp ../desktop/bin/StatusIm StatusIm.app/Contents/MacOs'
|
|
|
|
sh """
|
|
|
|
macdeployqt StatusIm.app -verbose=1 -dmg \\
|
|
|
|
-qmldir='${workspace}/node_modules/react-native/ReactQt/runtime/src/qml/'
|
|
|
|
"""
|
|
|
|
sh 'rm -f StatusAppFiles'
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
stage('Archive Artifact') {
|
|
|
|
archiveArtifacts 'StatusImPackage/*.dmg'
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
slackNotify('MacOS build finished successfully.')
|
2018-07-23 15:21:31 +00:00
|
|
|
} catch (e) {
|
2018-08-06 15:12:32 +00:00
|
|
|
slackNotify('Failed to build on MacOS.', color: 'bad')
|
2018-07-23 15:21:31 +00:00
|
|
|
throw e
|
2018-08-06 15:12:32 +00:00
|
|
|
} finally {
|
|
|
|
cleanupBuild()
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-08-06 15:12:32 +00:00
|
|
|
'Linux build': {
|
2018-07-23 15:21:31 +00:00
|
|
|
timeout(90) {
|
2018-08-06 15:12:32 +00:00
|
|
|
node ('linux-01') {
|
|
|
|
def qt_bin = '/opt/qt59/bin'
|
2018-07-23 15:21:31 +00:00
|
|
|
|
|
|
|
try {
|
2018-08-06 15:12:32 +00:00
|
|
|
stage('Git & Deps') {
|
|
|
|
slackNotify('Linux build started.')
|
2018-07-23 15:21:31 +00:00
|
|
|
checkout scm
|
|
|
|
doGitRebase()
|
2018-08-06 15:12:32 +00:00
|
|
|
cleanupAndDeps()
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build ClojureScript') {
|
2018-08-06 15:12:32 +00:00
|
|
|
buildClojureScript()
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build Linux binaries') {
|
2018-08-06 15:12:32 +00:00
|
|
|
/* add path for QT installation binaries */
|
|
|
|
env.PATH = "${qt_bin}:${env.PATH}"
|
|
|
|
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'
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
stage('Create Linux AppImage') {
|
|
|
|
dir(packageFolder) {
|
|
|
|
sh 'rm -rf StatusImAppImage'
|
|
|
|
/* TODO this needs to be fixed: status-react/issues/5378 */
|
|
|
|
sh 'cp /opt/StatusImAppImage.zip ./'
|
|
|
|
sh 'unzip ./StatusImAppImage.zip'
|
|
|
|
sh 'rm -rf AppDir'
|
|
|
|
sh 'mkdir AppDir'
|
|
|
|
}
|
|
|
|
sh "cp -r ./deployment/linux/usr ${packageFolder}/AppDir"
|
|
|
|
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'
|
2018-07-23 15:21:31 +00:00
|
|
|
|
|
|
|
sh 'rm -f Application-x86_64.AppImage'
|
|
|
|
sh 'rm -f StatusIm-x86_64.AppImage'
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
sh "ldd ${packageFolder}/AppDir/usr/bin/StatusIm"
|
|
|
|
sh """
|
|
|
|
./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=${qt_bin}/qmake \\
|
|
|
|
-extra-plugins=imageformats/libqsvg.so \\
|
|
|
|
-qmldir='${workspace}/node_modules/react-native'
|
|
|
|
"""
|
|
|
|
dir(packageFolder) {
|
|
|
|
sh 'ldd AppDir/usr/bin/StatusIm'
|
|
|
|
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'
|
|
|
|
}
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
stage('Archive Artifact') {
|
|
|
|
archiveArtifacts 'StatusImPackage/*.AppImage'
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 15:12:32 +00:00
|
|
|
slackNotify('Linux build finished successfully.')
|
2018-07-23 15:21:31 +00:00
|
|
|
} catch (e) {
|
2018-08-06 15:12:32 +00:00
|
|
|
slackNotify('Failed to build on Linux.', color: 'bad')
|
2018-07-23 15:21:31 +00:00
|
|
|
throw e
|
2018-08-06 15:12:32 +00:00
|
|
|
} finally {
|
|
|
|
cleanupBuild()
|
2018-07-23 15:21:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|