diff --git a/Jenkinsfile.nightly_fastlane b/Jenkinsfile.nightly_fastlane index 99f13130cb..885b051a82 100644 --- a/Jenkinsfile.nightly_fastlane +++ b/Jenkinsfile.nightly_fastlane @@ -46,6 +46,20 @@ timeout(90) { sh 'cd ios && pod install && cd ..' } + stage('Tag Build') { + withCredentials([[ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'jenkins-status-im', + usernameVariable: 'GIT_USER', + passwordVariable: 'GIT_PASS' + ]]) { + def build_no = sh( + returnStdout: true, + script: './scripts/build_no.sh --increment' + ).trim() + } + } + stage('Tests') { sh 'lein test-cljs' } @@ -60,7 +74,6 @@ timeout(90) { stage('Build (iOS)') { withCredentials([string(credentialsId: 'jenkins_pass', variable: 'password')]) { - def build_no = sh(returnStdout: true, script: './scripts/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' diff --git a/Jenkinsfile.release b/Jenkinsfile.release index acf0f92927..f861ab1fb3 100644 --- a/Jenkinsfile.release +++ b/Jenkinsfile.release @@ -43,8 +43,22 @@ timeout(90) { installJSDeps() sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack' - sh 'cd ios && pod install && cd ..' + sh 'cd ios && pod install && cd ..' + } + + stage('Tag Build') { + withCredentials([[ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'jenkins-status-im', + usernameVariable: 'GIT_USER', + passwordVariable: 'GIT_PASS' + ]]) { + def build_no = sh( + returnStdout: true, + script: './scripts/build_no.sh --increment' + ).trim() } + } stage('Tests') { sh 'lein test-cljs' @@ -59,7 +73,6 @@ timeout(90) { } stage('Build (iOS)') { - def build_no = sh(returnStdout: true, script: './scripts/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' @@ -94,16 +107,6 @@ timeout(90) { } } - 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 diff --git a/Jenkinsfile.upload_release_android b/Jenkinsfile.upload_release_android index 56ed9af973..13763d1bfb 100644 --- a/Jenkinsfile.upload_release_android +++ b/Jenkinsfile.upload_release_android @@ -47,8 +47,22 @@ timeout(90) { installJSDeps() sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack' - sh 'cd ios && pod install && cd ..' + sh 'cd ios && pod install && cd ..' + } + + stage('Tag Build') { + withCredentials([[ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'jenkins-status-im', + usernameVariable: 'GIT_USER', + passwordVariable: 'GIT_PASS' + ]]) { + def build_no = sh( + returnStdout: true, + script: './scripts/build_no.sh --increment' + ).trim() } + } stage('Tests') { sh 'lein test-cljs' diff --git a/Jenkinsfile.upload_release_ios b/Jenkinsfile.upload_release_ios index 26378723f0..0257eba530 100644 --- a/Jenkinsfile.upload_release_ios +++ b/Jenkinsfile.upload_release_ios @@ -46,8 +46,22 @@ timeout(90) { installJSDeps() sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack' - sh 'cd ios && pod install && cd ..' + sh 'cd ios && pod install && cd ..' + } + + stage('Tag Build') { + withCredentials([[ + $class: 'UsernamePasswordMultiBinding', + credentialsId: 'jenkins-status-im', + usernameVariable: 'GIT_USER', + passwordVariable: 'GIT_PASS' + ]]) { + def build_no = sh( + returnStdout: true, + script: './scripts/build_no.sh --increment' + ).trim() } + } stage('Tests') { sh 'lein test-cljs' @@ -59,7 +73,6 @@ timeout(90) { stage('Build (iOS)') { withCredentials([string(credentialsId: 'jenkins_pass', variable: 'password')]) { - def build_no = sh(returnStdout: true, script: './scripts/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' diff --git a/scripts/build_no.sh b/scripts/build_no.sh index 03d392fa73..b5ee52b811 100755 --- a/scripts/build_no.sh +++ b/scripts/build_no.sh @@ -1,5 +1,7 @@ #!/usr/bin/env sh +set -e + # # This script manages app build numbers. # It returns the next build number to be used. @@ -25,8 +27,7 @@ getNumber () { REGEX='^build-[0-9]\+$' # make sure we have all the tags -git fetch --tags --quiet - +git fetch --tags --quiet >/dev/null # even if the current commit has a tag already, it is normal that the same commit # is built multiple times (with different build configurations, for instance), @@ -36,13 +37,19 @@ git fetch --tags --quiet BUILD=$(git tag -l --sort=-v:refname | grep -e "$REGEX" | head -n 1) # extract the number BUILD_NO=$(getNumber "$BUILD") -# increment -BUILD_NO="$((BUILD_NO+1))" -if [ "$1" = "--tag" ]; then +if [ "$1" = "--increment" ]; then + # These need to be provided by Jenkins + if [ -z "${GIT_USER}" ] || [ -z "${GIT_PASS}" ]; then + echo "Git credentials not specified! (GIT_USER, GIT_PASS)" >&2 + exit 1 + fi + # increment + BUILD_NO="$((BUILD_NO+1))" + echo "Tagging HEAD: build-$BUILD_NO" >&2 - echo "You will need to 'git push --tags' to make this tag take effect." >&2 git tag "build-$BUILD_NO" HEAD + git push --tags https://${GIT_USER}:${GIT_PASS}@github.com/status-im/status-react fi # finally print build number