95 lines
4.3 KiB
Groovy
95 lines
4.3 KiB
Groovy
pipeline {
|
|
agent {
|
|
label 'flutter'
|
|
}
|
|
options {
|
|
disableConcurrentBuilds()
|
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
|
}
|
|
parameters {
|
|
string(name: 'APP_TITLE', defaultValue: 'Embedded Webview', description: 'Application title')
|
|
string(name: 'APP_URI', defaultValue: 'https://www.charlyghislain.com', description: 'Application uri')
|
|
string(name: 'APP_COLOR', defaultValue: 'red', description: 'Application color (blue, teal, ...)')
|
|
string(name: 'BUILD_MODE', defaultValue: 'debug', description: 'Flutter build mode (debug/release)')
|
|
string(name: 'UPLOAD_TRACK', defaultValue: 'alpha', description: 'Upload track')
|
|
string(name: 'RELEASE_MESSAGE', defaultValue: 'Nouvelle version', description: 'A release message')
|
|
string(name: 'RELEASE_STATUS', defaultValue: 'completed', description: 'draft/completed')
|
|
booleanParam(name: 'SKIP_PUBLISH', defaultValue: 'true', description: 'Skip publishing apk')
|
|
string(name: 'GIT_CREDENTIAL_ID', defaultValue: 'jenkins-jenkins-ssh-key', description: '')
|
|
string(name: 'GIT_PUSH_BRANCH', defaultValue: 'android-releases', description: 'A branch to push the commit')
|
|
string(name: 'GIT_TAG', defaultValue: '', description: 'An additional tag to push')
|
|
booleanParam(name: 'SKIP_PUSH_TAG', defaultValue: 'true', description: 'Skip push tag')
|
|
string(name: 'NODEJS_INSTALLATION', defaultValue: 'node14',description: 'Nodejs installation to use')
|
|
}
|
|
stages {
|
|
stage ('Build') {
|
|
steps {
|
|
script {
|
|
env.APP_TITLE= params.APP_TITLE
|
|
env.APP_URI= params.APP_URI
|
|
env.APP_COLOR= params.APP_COLOR
|
|
env.BUILD_MODE= params.BUILD_MODE
|
|
}
|
|
container ('flutter') {
|
|
sshagent(["${params.GIT_CREDENTIAL_ID}"]) {
|
|
sh 'flutter doctor'
|
|
sh 'GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/var/run/ssh/known_hosts.gitea.fteamdev.valuya.be" flutter pub get'
|
|
sh 'flutter clean'
|
|
sh 'APP_TITLE="$APP_TITLE" APP_URI="$APP_URI" APP_COLOR="$APP_COLOR" BUILDMODE="$BUILD_MODEs" ./tools/jenkins-build-android.sh'
|
|
stash(name: 'outputs', includes: 'build/app/outputs/**')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage ('Push') {
|
|
when { anyOf {
|
|
expression {return (params.SKIP_PUBLISH == false)}
|
|
expression {return (env.GIT_BRANCH == "master" )}
|
|
}}
|
|
steps {
|
|
script {
|
|
env.SKIP_PUSH_TAG= params.SKIP_PUSH_TAG
|
|
env.GIT_TAG= params.GIT_TAG
|
|
env.GIT_PUSH_BRANCH = params.GIT_PUSH_BRANCH
|
|
env.TRACK = params.UPLOAD_TRACK
|
|
env.RELEASE_STATUS = params.RELEASE_STATUS
|
|
env.RELEASE_MESSAGE = params.RELEASE_MESSAGE
|
|
}
|
|
unstash(name: 'outputs')
|
|
sshagent(["${params.GIT_CREDENTIAL_ID}"]) {
|
|
nodejs(nodeJSInstallationName: "${params.NODEJS_INSTALLATION}") {
|
|
sh './tools/jenkins-publish-android.sh'
|
|
}
|
|
sh '''
|
|
VERSION_CODE=$(./tools/jenkins-increment-buildnumber.sh || echo $?)
|
|
[ "$VERSION_CODE" == "0" ] && exit 1
|
|
git config user.email "jenkins@valuya.com"
|
|
git config user.name "Jenkins release"
|
|
git add pubspec.yaml
|
|
git remote add ssh "ssh://git@gitea.valuya.com:2022/Valuya/embedded_webview.git"
|
|
git commit -m "Bump to build $VERSION_CODE"
|
|
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/var/run/ssh/known_hosts.gitea.valuya.com"
|
|
git push ssh HEAD:$GIT_PUSH_BRANCH
|
|
if [ "$SKIP_PUSH_TAG" != "true" ] ; then
|
|
git tag "$GIT_TAG"
|
|
git push ssh "$GIT_TAG"
|
|
fi
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
failure {
|
|
mail(
|
|
to: 'charlyghislain@gmail.com',
|
|
subject: "Release failed: $JOB_NAME ${params.GIT_REPO_BRANCH} ${BUILD_NUMBER}",
|
|
body: "See job at ${BUILD_URL}"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
|