Timeout and abort Jenkins jobs after 90 minutes.

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Igor Mandrigin 2018-05-21 16:47:30 +02:00
parent 1aae1a9645
commit ff86ea7f95
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
7 changed files with 569 additions and 554 deletions

198
Jenkinsfile vendored
View File

@ -14,117 +14,119 @@ def installJSDeps() {
}
}
node ('macos') {
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def branch;
timeout(90) {
node ('macos') {
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def branch;
load "$HOME/env.groovy"
load "$HOME/env.groovy"
try {
try {
stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + '(' + env.CHANGE_BRANCH + ') build started. ' + env.BUILD_URL
stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + '(' + env.CHANGE_BRANCH + ') build started. ' + env.BUILD_URL
checkout scm
sh 'git rebase origin/develop'
checkout scm
sh 'git rebase origin/develop'
sh 'rm -rf node_modules'
sh 'cp .env.jenkins .env'
sh 'lein deps'
sh 'rm -rf node_modules'
sh 'cp .env.jenkins .env'
sh 'lein deps'
installJSDeps()
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Code style checks') {
sh 'lein cljfmt check'
}
stage('Code style checks') {
sh 'lein cljfmt check'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build') {
sh 'lein prod-build'
}
// Android
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
}
// Android
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
}
stage('Deploy (Android)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token'), string(credentialsId: 'GIT_HUB_TOKEN', variable: 'githubToken')] ) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
stage('Deploy (Android)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token'), string(credentialsId: 'GIT_HUB_TOKEN', variable: 'githubToken')] ) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
def commentMsg = "apk uploaded to " + apkUrl + " for branch " + BRANCH_NAME
def ghOutput = sh(returnStdout: true, script: "curl -u status-im:" + githubToken + " -H 'Content-Type: application/json' --data '{\"body\": \"" + commentMsg + "\"}' https://api.github.com/repos/status-im/status-react/issues/" + CHANGE_ID + "/comments")
println("Result of github comment curl: " + ghOutput)
sh ('echo ARTIFACT Android: ' + apkUrl)
def commentMsg = "apk uploaded to " + apkUrl + " for branch " + BRANCH_NAME
def ghOutput = sh(returnStdout: true, script: "curl -u status-im:" + githubToken + " -H 'Content-Type: application/json' --data '{\"body\": \"" + commentMsg + "\"}' https://api.github.com/repos/status-im/status-react/issues/" + CHANGE_ID + "/comments")
println("Result of github comment curl: " + ghOutput)
sh ('echo ARTIFACT Android: ' + apkUrl)
}
}
// iOS
stage('Build (iOS)') {
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token'), string(credentialsId: 'GIT_HUB_TOKEN', variable: 'githubToken')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
def commentMsg = "ipa uploaded to " + ipaUrl + " for branch " + BRANCH_NAME
def ghOutput = sh(returnStdout: true, script: "curl -u status-im:" + githubToken + " -H 'Content-Type: application/json' --data '{\"body\": \"" + commentMsg + "\"}' https://api.github.com/repos/status-im/status-react/issues/" + CHANGE_ID + "/comments")
println("Result of github comment curl: " + ghOutput)
sh ('echo ARTIFACT iOS: ' + ipaUrl)
}
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Branch: ' + BRANCH_NAME +
'\nAndroid: ' + apkUrl +
'\niOS: ' + ipaUrl
}
// Android for e2e
stage('Build (Android) for e2e tests') {
sh 'cd android && mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/app-release.original.apk && ENVFILE=.env.e2e ./gradlew assembleRelease'
}
stage('Upload apk for e2e tests') {
if (env.CHANGE_ID != null){
withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){
def apk_name = env.CHANGE_ID + '.apk'
sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk')
}
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT Android for e2e tests: ' + apkUrl)
}
}
}
} catch (e) {
slackSend color: 'bad', message: BRANCH_NAME + ' failed to build. ' + env.BUILD_URL
throw e
}
}
// iOS
stage('Build (iOS)') {
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token'), string(credentialsId: 'GIT_HUB_TOKEN', variable: 'githubToken')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
def commentMsg = "ipa uploaded to " + ipaUrl + " for branch " + BRANCH_NAME
def ghOutput = sh(returnStdout: true, script: "curl -u status-im:" + githubToken + " -H 'Content-Type: application/json' --data '{\"body\": \"" + commentMsg + "\"}' https://api.github.com/repos/status-im/status-react/issues/" + CHANGE_ID + "/comments")
println("Result of github comment curl: " + ghOutput)
sh ('echo ARTIFACT iOS: ' + ipaUrl)
}
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Branch: ' + BRANCH_NAME +
'\nAndroid: ' + apkUrl +
'\niOS: ' + ipaUrl
}
// Android for e2e
stage('Build (Android) for e2e tests') {
sh 'cd android && mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/app-release.original.apk && ENVFILE=.env.e2e ./gradlew assembleRelease'
}
stage('Upload apk for e2e tests') {
if (env.CHANGE_ID != null){
withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){
def apk_name = env.CHANGE_ID + '.apk'
sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk')
}
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT Android for e2e tests: ' + apkUrl)
}
}
}
} catch (e) {
slackSend color: 'bad', message: BRANCH_NAME + ' failed to build. ' + env.BUILD_URL
throw e
}
}

View File

@ -2,21 +2,24 @@ env.LANG="en_US.UTF-8"
env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
node ('macos'){
stage('Git & Dependencies'){
timeout(90) {
node ('macos'){
checkout([$class: 'GitSCM', branches: [[name: 'develop']],
doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']],
submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/status-im/status-react.git']]])
stage('Git & Dependencies'){
load "$HOME/env.groovy"
}
stage('Clean Testflight Users'){
withCredentials([string(credentialsId: 'FASTLANE_PASSWORD', variable: 'FASTLANE_PASSWORD'),
string(credentialsId: 'APPLE_ID', variable: 'APPLE_ID')]) {
sh ('bundle install')
sh ('bundle exec fastlane ios clean')}}
checkout([$class: 'GitSCM', branches: [[name: 'develop']],
doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']],
submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/status-im/status-react.git']]])
load "$HOME/env.groovy"
}
stage('Clean Testflight Users'){
withCredentials([string(credentialsId: 'FASTLANE_PASSWORD', variable: 'FASTLANE_PASSWORD'),
string(credentialsId: 'APPLE_ID', variable: 'APPLE_ID')]) {
sh ('bundle install')
sh ('bundle exec fastlane ios clean')}}
}
}

View File

@ -17,102 +17,104 @@ def installJSDeps() {
}
}
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
timeout(90) {
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
load "$HOME/env.groovy"
load "$HOME/env.groovy"
try {
try {
stage('Git & Dependencies') {
slackSend color: 'good', message: 'Nightly build started. ' + env.BUILD_URL
stage('Git & Dependencies') {
slackSend color: 'good', message: 'Nightly build started. ' + env.BUILD_URL
checkout scm
checkout scm
sh 'rm -rf node_modules'
sh 'cp .env.jenkins .env'
sh 'lein deps'
installJSDeps()
sh 'rm -rf node_modules'
sh 'cp .env.jenkins .env'
sh 'lein deps'
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
}
stage('Build (iOS)') {
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (Android)') {
def artifact_dir = pwd() + '/android/app/build/outputs/apk/release/'
println (artifact_dir + 'app-release.apk')
sh ('ls -la ' + artifact_dir)
def artifact = (artifact_dir + 'app-release.apk')
def server = Artifactory.server('artifacts')
def shortCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim().take(6)
def filename = 'im.status.ethereum-' + shortCommit + '.apk'
def newArtifact = (artifact_dir + filename)
sh ('mv ' + artifact + ' ' + newArtifact)
def uploadSpec = '{ "files": [ { "pattern": "*apk/release/' + filename + '", "target": "nightlies-local" }]}'
def buildInfo = server.upload(uploadSpec)
apkUrl = 'http://artifacts.status.im:8081/artifactory/nightlies-local/' + filename
sh ('echo ARTIFACT Android: ' + apkUrl)
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT iOS: ' + ipaUrl)
}
}
} catch (e) {
slackSend color: 'bad', message: 'Nightly build (develop) failed to build. ' + env.BUILD_URL
throw e
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Nightly build (develop) \nTests: ' + (testPassed ? ':+1:' : ':-1:') + ')\nAndroid: ' + apkUrl + '\n iOS: ' + ipaUrl
build job: 'status-react/status-nightly-publish-link', parameters: [[$class: 'StringParameterValue', name: 'APK_URL', value: apkUrl], [$class: 'StringParameterValue', name: 'IOS_URL', value: ipaUrl]]
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android) for e2e tests') {
sh 'cd android && mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/app-release.original.apk && ENVFILE=.env.e2e ./gradlew assembleRelease'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
}
stage('Upload apk for e2e tests') {
if (env.CHANGE_ID != null){
withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){
def apk_name = env.CHANGE_ID + '.apk'
sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk')
}
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
stage('Build (iOS)') {
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (Android)') {
def artifact_dir = pwd() + '/android/app/build/outputs/apk/release/'
println (artifact_dir + 'app-release.apk')
sh ('ls -la ' + artifact_dir)
def artifact = (artifact_dir + 'app-release.apk')
def server = Artifactory.server('artifacts')
def shortCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim().take(6)
def filename = 'im.status.ethereum-' + shortCommit + '.apk'
def newArtifact = (artifact_dir + filename)
sh ('mv ' + artifact + ' ' + newArtifact)
def uploadSpec = '{ "files": [ { "pattern": "*apk/release/' + filename + '", "target": "nightlies-local" }]}'
def buildInfo = server.upload(uploadSpec)
apkUrl = 'http://artifacts.status.im:8081/artifactory/nightlies-local/' + filename
sh ('echo ARTIFACT Android: ' + apkUrl)
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT iOS: ' + ipaUrl)
sh ('echo ARTIFACT Android for e2e tests: ' + apkUrl)
}
}
}
}
} catch (e) {
slackSend color: 'bad', message: 'Nightly build (develop) failed to build. ' + env.BUILD_URL
throw e
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Nightly build (develop) \nTests: ' + (testPassed ? ':+1:' : ':-1:') + ')\nAndroid: ' + apkUrl + '\n iOS: ' + ipaUrl
build job: 'status-react/status-nightly-publish-link', parameters: [[$class: 'StringParameterValue', name: 'APK_URL', value: apkUrl], [$class: 'StringParameterValue', name: 'IOS_URL', value: ipaUrl]]
}
stage('Build (Android) for e2e tests') {
sh 'cd android && mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/app-release.original.apk && ENVFILE=.env.e2e ./gradlew assembleRelease'
}
stage('Upload apk for e2e tests') {
if (env.CHANGE_ID != null){
withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){
def apk_name = env.CHANGE_ID + '.apk'
sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk')
}
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT Android for e2e tests: ' + apkUrl)
}
}
}
}

View File

@ -17,120 +17,122 @@ def installJSDeps() {
}
}
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def latest_tag;
timeout(90) {
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def latest_tag;
load "$HOME/env.groovy"
load "$HOME/env.groovy"
try {
try {
stage('Git & Dependencies') {
slackSend color: 'good', message: 'Nightly build started. ' + env.BUILD_URL
stage('Git & Dependencies') {
slackSend color: 'good', message: 'Nightly build started. ' + env.BUILD_URL
checkout scm
checkout scm
sh 'git fetch --tags'
latest_tag = sh(returnStdout: true, script: 'git describe --tags `git rev-list --tags=release --max-count=1`').trim()
sh 'rm -rf node_modules'
sh 'cp .env.nightly .env'
sh 'lein deps'
installJSDeps()
sh 'git fetch --tags'
latest_tag = sh(returnStdout: true, script: 'git describe --tags `git rev-list --tags=release --max-count=1`').trim()
sh 'rm -rf node_modules'
sh 'cp .env.nightly .env'
sh 'lein deps'
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
}
stage('Build (iOS)') {
withCredentials([string(credentialsId: 'jenkins_pass', variable: 'password')]) {
def build_no = sh(returnStdout: true, script: 'git rev-list --count HEAD').trim()
sh ('plutil -replace CFBundleShortVersionString -string ' + latest_tag + ' ios/StatusIm/Info.plist')
sh ('plutil -replace CFBundleVersion -string ' + build_no + ' ios/StatusIm/Info.plist')
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh ('security unlock-keychain -p ' + password + ' login.keychain')
sh 'xcodebuild -exportArchive -exportPath status_appstore -archivePath status.xcarchive -exportOptionsPlist ~/archive-release.plist'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
}
stage('Deploy (Android)') {
def artifact_dir = pwd() + '/android/app/build/outputs/apk/release/'
println (artifact_dir + 'app-release.apk')
def artifact = (artifact_dir + 'app-release.apk')
def server = Artifactory.server('artifacts')
shortCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim().take(6)
def filename = 'im.status.ethereum-' + shortCommit + '.apk'
def newArtifact = (artifact_dir + filename)
sh ('cp ' + artifact + ' ' + newArtifact)
def uploadSpec = '{ "files": [ { "pattern": "*apk/release/' + filename + '", "target": "nightlies-local" }]}'
def buildInfo = server.upload(uploadSpec)
apkUrl = 'http://artifacts.status.im:8081/artifactory/nightlies-local/' + filename
//todo: handle version differently instead of exit 0
sh ('bundle exec fastlane android nightly || exit 0')
sh ('echo ARTIFACT Android: ' + apkUrl)
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
//todo: handle version differently instead of exit 0
sh ('bundle exec fastlane ios nightly || exit 0')
sh ('echo ARTIFACT iOS: ' + ipaUrl)
}
}
} catch (e) {
slackSend color: 'bad', message: 'Nightly build (develop) failed to build. ' + env.BUILD_URL
throw e
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Run status-nightly-publish-link job') {
build job: 'status-react/status-nightly-publish-link', parameters: [[$class: 'StringParameterValue', name: 'APK_URL', value: apkUrl], [$class: 'StringParameterValue', name: 'IOS_URL', value: ipaUrl]]
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android) for e2e tests') {
sh 'cd android && mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/app-release.original.apk && ENVFILE=.env.e2e ./gradlew assembleRelease'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
}
stage('Upload apk for e2e tests') {
withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){
apk_name = 'im.status.ethereum-e2e-' + shortCommit + '.apk'
sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk')
}
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
testApkUrl = 'https://i.diawi.com/' + hash
stage('Build (iOS)') {
withCredentials([string(credentialsId: 'jenkins_pass', variable: 'password')]) {
def build_no = sh(returnStdout: true, script: 'git rev-list --count HEAD').trim()
sh ('plutil -replace CFBundleShortVersionString -string ' + latest_tag + ' ios/StatusIm/Info.plist')
sh ('plutil -replace CFBundleVersion -string ' + build_no + ' ios/StatusIm/Info.plist')
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh ('security unlock-keychain -p ' + password + ' login.keychain')
sh 'xcodebuild -exportArchive -exportPath status_appstore -archivePath status.xcarchive -exportOptionsPlist ~/archive-release.plist'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
sh ('echo ARTIFACT Android for e2e tests: ' + testApkUrl)
}
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Nightly build (develop) \nTests: ' + (testPassed ? ':+1:' : ':-1:') + ')\nAndroid: ' + apkUrl + '\n iOS: ' + ipaUrl + '\n Android for e2e: ' + testApkUrl
}
stage('Run extended e2e tests') {
build job: 'end-to-end-tests/status-app-nightly', parameters: [string(name: 'apk', value: '--apk=' + apk_name)], wait: false
}
}
stage('Deploy (Android)') {
def artifact_dir = pwd() + '/android/app/build/outputs/apk/release/'
println (artifact_dir + 'app-release.apk')
def artifact = (artifact_dir + 'app-release.apk')
def server = Artifactory.server('artifacts')
shortCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim().take(6)
def filename = 'im.status.ethereum-' + shortCommit + '.apk'
def newArtifact = (artifact_dir + filename)
sh ('cp ' + artifact + ' ' + newArtifact)
def uploadSpec = '{ "files": [ { "pattern": "*apk/release/' + filename + '", "target": "nightlies-local" }]}'
def buildInfo = server.upload(uploadSpec)
apkUrl = 'http://artifacts.status.im:8081/artifactory/nightlies-local/' + filename
//todo: handle version differently instead of exit 0
sh ('bundle exec fastlane android nightly || exit 0')
sh ('echo ARTIFACT Android: ' + apkUrl)
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
//todo: handle version differently instead of exit 0
sh ('bundle exec fastlane ios nightly || exit 0')
sh ('echo ARTIFACT iOS: ' + ipaUrl)
}
}
} catch (e) {
slackSend color: 'bad', message: 'Nightly build (develop) failed to build. ' + env.BUILD_URL
throw e
}
stage('Run status-nightly-publish-link job') {
build job: 'status-react/status-nightly-publish-link', parameters: [[$class: 'StringParameterValue', name: 'APK_URL', value: apkUrl], [$class: 'StringParameterValue', name: 'IOS_URL', value: ipaUrl]]
}
stage('Build (Android) for e2e tests') {
sh 'cd android && mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/app-release.original.apk && ENVFILE=.env.e2e ./gradlew assembleRelease'
}
stage('Upload apk for e2e tests') {
withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){
apk_name = 'im.status.ethereum-e2e-' + shortCommit + '.apk'
sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk')
}
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
testApkUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT Android for e2e tests: ' + testApkUrl)
}
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Nightly build (develop) \nTests: ' + (testPassed ? ':+1:' : ':-1:') + ')\nAndroid: ' + apkUrl + '\n iOS: ' + ipaUrl + '\n Android for e2e: ' + testApkUrl
}
stage('Run extended e2e tests') {
build job: 'end-to-end-tests/status-app-nightly', parameters: [string(name: 'apk', value: '--apk=' + apk_name)], wait: false
}
}

View File

@ -14,112 +14,114 @@ def installJSDeps() {
}
}
node ('macos') {
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def branch;
timeout(90) {
node ('macos') {
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def branch;
load "$HOME/env.groovy"
load "$HOME/env.groovy"
try {
try {
stage('Git & Dependencies') {
slackSend color: 'good', message: REPO + ":" + BRANCH_NAME + ' build started. ' + env.BUILD_URL
stage('Git & Dependencies') {
slackSend color: 'good', message: REPO + ":" + BRANCH_NAME + ' build started. ' + env.BUILD_URL
checkout scm
checkout scm
sh 'rm -rf node_modules'
sh 'rm -rf node_modules'
sh 'test ${JENKINS_REBASE_DEVELOP} -eq 1 && git rebase origin/develop || echo "Not rebasing on develop."'
sh 'test ${JENKINS_REBASE_DEVELOP} -eq 1 && git rebase origin/develop || echo "Not rebasing on develop."'
// Assume all parameters are set in Jenkins 'Parameterized build'
// TODO(oskarth): Consider read/write from .env to avoid having to specify in Jenkins again
// sh 'cp .env.jenkins .env'
sh 'echo TESTFAIRY_ENABLED=' + TESTFAIRY_ENABLED + '>>' + '.env'
sh 'echo STUB_STATUS_GO=' + STUB_STATUS_GO + '>>' + '.env'
sh 'echo ETHEREUM_DEV_CLUSTER=' + ETHEREUM_DEV_CLUSTER + '>>' + '.env'
sh 'echo MAINNET_NETWORKS_ENABLED=' + MAINNET_NETWORKS_ENABLED + '>>' + '.env'
sh 'echo LOG_LEVEL=' + LOG_LEVEL + '>>' + '.env'
sh 'echo LOG_LEVEL_STATUS_GO=' + LOG_LEVEL_STATUS_GO + '>>' + '.env'
sh 'echo OFFLINE_INBOX_ENABLED=' + OFFLINE_INBOX_ENABLED + '>>' + '.env'
sh 'echo POW_TARGET=' + POW_TARGET + '>>' + '.env'
sh 'echo POW_TIME=' + POW_TIME + '>>' + '.env'
sh 'echo MAINNET_WARNING_ENABLED=' + MAINNET_WARNING_ENABLED + '>>' + '.env'
sh 'echo DEFAULT_NETWORK=' + DEFAULT_NETWORK + '>>' + '.env'
// Assume all parameters are set in Jenkins 'Parameterized build'
// TODO(oskarth): Consider read/write from .env to avoid having to specify in Jenkins again
// sh 'cp .env.jenkins .env'
sh 'echo TESTFAIRY_ENABLED=' + TESTFAIRY_ENABLED + '>>' + '.env'
sh 'echo STUB_STATUS_GO=' + STUB_STATUS_GO + '>>' + '.env'
sh 'echo ETHEREUM_DEV_CLUSTER=' + ETHEREUM_DEV_CLUSTER + '>>' + '.env'
sh 'echo MAINNET_NETWORKS_ENABLED=' + MAINNET_NETWORKS_ENABLED + '>>' + '.env'
sh 'echo LOG_LEVEL=' + LOG_LEVEL + '>>' + '.env'
sh 'echo LOG_LEVEL_STATUS_GO=' + LOG_LEVEL_STATUS_GO + '>>' + '.env'
sh 'echo OFFLINE_INBOX_ENABLED=' + OFFLINE_INBOX_ENABLED + '>>' + '.env'
sh 'echo POW_TARGET=' + POW_TARGET + '>>' + '.env'
sh 'echo POW_TIME=' + POW_TIME + '>>' + '.env'
sh 'echo MAINNET_WARNING_ENABLED=' + MAINNET_WARNING_ENABLED + '>>' + '.env'
sh 'echo DEFAULT_NETWORK=' + DEFAULT_NETWORK + '>>' + '.env'
sh 'echo "**********************************************************************"'
sh 'echo PARAMETERIZED BUILD - USING CUSTOM ENVIRONMENT'
sh 'cat .env'
sh 'echo "**********************************************************************"'
sh 'echo "**********************************************************************"'
sh 'echo PARAMETERIZED BUILD - USING CUSTOM ENVIRONMENT'
sh 'cat .env'
sh 'echo "**********************************************************************"'
sh 'lein deps'
installJSDeps()
sh 'lein deps'
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
// Android
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Deploy (Android)') {
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
// Android
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease'
}
stage('Deploy (Android)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT Android: ' + apkUrl)
}
}
// try {
// stage('Test (Android)') {
// sauce('b9aded57-5cc1-4f6b-b5ea-42d989987852') {
// sh 'cd test/appium && mvn -DapkUrl=' + apkUrl + ' test'
// saucePublisher()
// }
// }
// } catch(e) {
// testPassed = false
// }
// iOS
stage('Build (iOS)') {
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@android/app/build/outputs/apk/release/app-release.apk -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
apkUrl = 'https://i.diawi.com/' + hash
ipaUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT iOS: ' + ipaUrl)
sh ('echo ARTIFACT Android: ' + apkUrl)
}
}
// try {
// stage('Test (Android)') {
// sauce('b9aded57-5cc1-4f6b-b5ea-42d989987852') {
// sh 'cd test/appium && mvn -DapkUrl=' + apkUrl + ' test'
// saucePublisher()
// }
// }
// } catch(e) {
// testPassed = false
// }
// iOS
stage('Build (iOS)') {
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT iOS: ' + ipaUrl)
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Branch: ' + REPO + ":" + BRANCH_NAME +
'\nAndroid: ' + apkUrl +
'\niOS: ' + ipaUrl
}
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Branch: ' + REPO + ":" + BRANCH_NAME +
'\nAndroid: ' + apkUrl +
'\niOS: ' + ipaUrl
} catch (e) {
slackSend color: 'bad', message: REPO + ":" + BRANCH_NAME + ' failed to build. ' + env.BUILD_URL
throw e
}
}
} catch (e) {
slackSend color: 'bad', message: REPO + ":" + BRANCH_NAME + ' failed to build. ' + env.BUILD_URL
throw e
}
}

View File

@ -17,104 +17,106 @@ def installJSDeps() {
}
}
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def version
timeout(90) {
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def version
load "$HOME/env.groovy"
load "$HOME/env.groovy"
try {
try {
stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL
stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL
if (!BRANCH_NAME.startsWith("release/")){
error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/version`"
if (!BRANCH_NAME.startsWith("release/")){
error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/version`"
}
checkout scm
version = BRANCH_NAME.substring(8)
sh 'echo "' + version + '" > .version'
sh 'git fetch --tags'
sh 'rm -rf node_modules'
sh 'cp .env.prod .env'
sh 'lein deps'
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease -PreleaseVersion=' + version
}
stage('Build (iOS)') {
def build_no = sh(returnStdout: true, script: './build_no.sh --tag').trim()
sh ('plutil -replace CFBundleShortVersionString -string ' + version + ' ios/StatusIm/Info.plist')
sh ('plutil -replace CFBundleVersion -string ' + build_no + ' ios/StatusIm/Info.plist')
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (Android)') {
def artifact_dir = pwd() + '/android/app/build/outputs/apk/release/'
println (artifact_dir + 'app-release.apk')
sh ('ls -la ' + artifact_dir)
def artifact = (artifact_dir + 'app-release.apk')
def server = Artifactory.server('artifacts')
def shortCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim().take(6)
def filename = 'im.status.ethereum-' + shortCommit + '.apk'
def newArtifact = (artifact_dir + filename)
sh ('mv ' + artifact + ' ' + newArtifact)
def uploadSpec = '{ "files": [ { "pattern": "*apk/release/' + filename + '", "target": "nightlies-local" }]}'
def buildInfo = server.upload(uploadSpec)
apkUrl = 'http://artifacts.status.im:8081/artifactory/nightlies-local/' + filename
sh ('echo ARTIFACT Android: ' + apkUrl)
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT iOS: ' + ipaUrl)
}
}
stage('Push build tag') {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'jenkins-status-im',
usernameVariable: 'GIT_USER',
passwordVariable: 'GIT_PASS'
]]) {
sh ('git push --tags https://${GIT_USER}:${GIT_PASS}@github.com/status-im/status-react --tags')
}
}
} catch (e) {
slackSend color: 'bad', message: 'Release build failed to build. ' + env.BUILD_URL
throw e
}
checkout scm
version = BRANCH_NAME.substring(8)
sh 'echo "' + version + '" > .version'
sh 'git fetch --tags'
sh 'rm -rf node_modules'
sh 'cp .env.prod .env'
sh 'lein deps'
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease -PreleaseVersion=' + version
}
stage('Build (iOS)') {
def build_no = sh(returnStdout: true, script: './build_no.sh --tag').trim()
sh ('plutil -replace CFBundleShortVersionString -string ' + version + ' ios/StatusIm/Info.plist')
sh ('plutil -replace CFBundleVersion -string ' + build_no + ' ios/StatusIm/Info.plist')
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh 'xcodebuild -exportArchive -exportPath status -archivePath status.xcarchive -exportOptionsPlist ~/archive.plist'
}
stage('Deploy (Android)') {
def artifact_dir = pwd() + '/android/app/build/outputs/apk/release/'
println (artifact_dir + 'app-release.apk')
sh ('ls -la ' + artifact_dir)
def artifact = (artifact_dir + 'app-release.apk')
def server = Artifactory.server('artifacts')
def shortCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim().take(6)
def filename = 'im.status.ethereum-' + shortCommit + '.apk'
def newArtifact = (artifact_dir + filename)
sh ('mv ' + artifact + ' ' + newArtifact)
def uploadSpec = '{ "files": [ { "pattern": "*apk/release/' + filename + '", "target": "nightlies-local" }]}'
def buildInfo = server.upload(uploadSpec)
apkUrl = 'http://artifacts.status.im:8081/artifactory/nightlies-local/' + filename
sh ('echo ARTIFACT Android: ' + apkUrl)
}
stage('Deploy (iOS)') {
withCredentials([string(credentialsId: 'diawi-token', variable: 'token')]) {
def job = sh(returnStdout: true, script: 'curl https://upload.diawi.com/ -F token='+token+' -F file=@status/StatusIm.ipa -F find_by_udid=0 -F wall_of_apps=0 | jq -r ".job"').trim()
sh 'sleep 10'
def hash = sh(returnStdout: true, script: "curl -vvv 'https://upload.diawi.com/status?token="+token+"&job="+job+"'|jq -r '.hash'").trim()
ipaUrl = 'https://i.diawi.com/' + hash
sh ('echo ARTIFACT iOS: ' + ipaUrl)
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Release build \nTests: ' + (testPassed ? ':+1:' : ':-1:') + ')\nAndroid: ' + apkUrl + '\n iOS: ' + ipaUrl
}
}
stage('Push build tag') {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'jenkins-status-im',
usernameVariable: 'GIT_USER',
passwordVariable: 'GIT_PASS'
]]) {
sh ('git push --tags https://${GIT_USER}:${GIT_PASS}@github.com/status-im/status-react --tags')
}
}
} catch (e) {
slackSend color: 'bad', message: 'Release build failed to build. ' + env.BUILD_URL
throw e
}
stage('Slack Notification') {
def c = (testPassed ? 'good' : 'warning' )
slackSend color: c, message: 'Release build \nTests: ' + (testPassed ? ':+1:' : ':-1:') + ')\nAndroid: ' + apkUrl + '\n iOS: ' + ipaUrl
}
}

View File

@ -17,87 +17,89 @@ def installJSDeps() {
}
}
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def version
timeout(90) {
node ('macos'){
def apkUrl = ''
def ipaUrl = ''
def testPassed = true
def version
load "$HOME/env.groovy"
load "$HOME/env.groovy"
try {
try {
stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL
stage('Git & Dependencies') {
slackSend color: 'good', message: BRANCH_NAME + ' build started. ' + env.BUILD_URL
if (!BRANCH_NAME.startsWith("release/")){
error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/version`"
if (!BRANCH_NAME.startsWith("release/")){
error "Wrong branch name format: " + BRANCH_NAME + ", but it should be `release/version`"
}
checkout scm
version = BRANCH_NAME.substring(8)
sh 'echo "' + version + '" > .version'
sh 'git fetch --tags'
sh 'rm -rf node_modules'
sh 'cp .env.prod .env'
sh 'lein deps'
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease -PreleaseVersion=' + version
}
stage('Build (iOS)') {
withCredentials([string(credentialsId: 'jenkins_pass', variable: 'password')]) {
def build_no = sh(returnStdout: true, script: './build_no.sh --tag').trim()
sh ('plutil -replace CFBundleShortVersionString -string ' + version + ' ios/StatusIm/Info.plist')
sh ('plutil -replace CFBundleVersion -string ' + build_no + ' ios/StatusIm/Info.plist')
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh ('security unlock-keychain -p ' + password + ' login.keychain')
sh 'xcodebuild -exportArchive -exportPath status_appstore -archivePath status.xcarchive -exportOptionsPlist ~/archive-release.plist'
}
}
stage('Deploy (Android)') {
sh ('bundle exec fastlane android release || exit 0')
}
stage('Deploy (iOS)') {
sh ('bundle exec fastlane ios release || exit 0')
}
stage('Push build tag') {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'jenkins-status-im',
usernameVariable: 'GIT_USER',
passwordVariable: 'GIT_PASS'
]]) {
sh ('git push --tags https://${GIT_USER}:${GIT_PASS}@github.com/status-im/status-react --tags')
}
}
} catch (e) {
slackSend color: 'bad', message: 'Release build failed uploading to iTC/Play Market. ' + env.BUILD_URL
throw e
}
checkout scm
version = BRANCH_NAME.substring(8)
sh 'echo "' + version + '" > .version'
sh 'git fetch --tags'
sh 'rm -rf node_modules'
sh 'cp .env.prod .env'
sh 'lein deps'
installJSDeps()
sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
}
stage('Tests') {
sh 'lein test-cljs'
}
stage('Build') {
sh 'lein prod-build'
}
stage('Build (Android)') {
sh 'cd android && ./gradlew assembleRelease -PreleaseVersion=' + version
}
stage('Build (iOS)') {
withCredentials([string(credentialsId: 'jenkins_pass', variable: 'password')]) {
def build_no = sh(returnStdout: true, script: './build_no.sh --tag').trim()
sh ('plutil -replace CFBundleShortVersionString -string ' + version + ' ios/StatusIm/Info.plist')
sh ('plutil -replace CFBundleVersion -string ' + build_no + ' ios/StatusIm/Info.plist')
sh 'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/StatusIm.xcworkspace -scheme StatusIm -configuration release -archivePath status clean archive'
sh ('security unlock-keychain -p ' + password + ' login.keychain')
sh 'xcodebuild -exportArchive -exportPath status_appstore -archivePath status.xcarchive -exportOptionsPlist ~/archive-release.plist'
stage('Slack Notification') {
slackSend color: 'good', message: 'Release build ' + version + ' succesfully aploade to iTC/Play Market'
}
}
stage('Deploy (Android)') {
sh ('bundle exec fastlane android release || exit 0')
}
stage('Deploy (iOS)') {
sh ('bundle exec fastlane ios release || exit 0')
}
stage('Push build tag') {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'jenkins-status-im',
usernameVariable: 'GIT_USER',
passwordVariable: 'GIT_PASS'
]]) {
sh ('git push --tags https://${GIT_USER}:${GIT_PASS}@github.com/status-im/status-react --tags')
}
}
} catch (e) {
slackSend color: 'bad', message: 'Release build failed uploading to iTC/Play Market. ' + env.BUILD_URL
throw e
}
stage('Slack Notification') {
slackSend color: 'good', message: 'Release build ' + version + ' succesfully aploade to iTC/Play Market'
}
}