tag and push within the script (#4540)

This commit is contained in:
Jakub 2018-06-12 10:08:09 +02:00 committed by GitHub
parent 3f3561123a
commit 9ac95d3ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 22 deletions

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -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'

View File

@ -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