#### 192.168.0.6为nginx代理地址,目的是为了转发
pipeline {
agent {
label 'PAL-1'
}
parameters {
gitParameter branch: '',
branchFilter: 'origin/(.*)',
defaultValue: 'master',
name: 'Branch',
quickFilterEnabled: false,
selectedValue: 'DEFAULT',
sortMode: 'NONE',
tagFilter: '*',
type: 'PT_BRANCH',
description: '代码分支'
}
stages {
stage('拉取项目代码') {
steps {
sh 'rm -rf ${WORKSPACE}/*'
checkout([$class: 'GitSCM', branches: [[name: '$Branch']], extensions: [], userRemoteConfigs: [[credentialsId: '***************************', url: 'http://*******/es-app.git']]])
}
}
stage("npm build") {
steps {
sh 'cd ${WORKSPACE}/ ; npm install react-native-blob-util --save ; npm run bundle-android'
}
}
stage("打包 apk") {
steps {
sh 'rm -rf ${WORKSPACE}/android/app/src/main/res/drawable-*'
sh 'rm -rf ${WORKSPACE}/android/app/src/main/res/raw'
sh 'cd ${WORKSPACE}/android && chmod +x gradlew && ./gradlew assembleRelease'
}
}
stage('目录名称') {
steps {
script {
if("${env.Branch}" == "master") {
env['Dir'] = "Master"
}else if("${env.Branch}" =~ "qa.*"){
env['Dir'] = "Qa"
}else if("${env.Branch}" =~ "dit.*"){
env['Dir'] = "Dev"
}else if("${env.Branch}" =~ "stage.*"){
env['Dir'] = "Stage"
}
}
}
}
stage('二维码js') {
steps {
script {
sh '''
cd ${WORKSPACE}
cat<<EOF>png.js
var qr = require('qr-image');
var fs = require('fs');
let arguments = process.argv.splice(2);
var url_string = arguments[0];
var save_qr_image_url= arguments[1];
var code = qr.image(url_string, { type: 'png', size: 10 });
console.log(code);
var pic = code.pipe(fs.createWriteStream(\\`\\${save_qr_image_url}/safettice.png\\`));
pic.on('error', (err)=> {
console.log(err);
});
pic.on('finish', ()=> {
console.log('二维码生成完毕');
});
EOF
'''
sh 'node png.js "http://192.168.0.6/$Dir/safettice.apk" ./'
}
}
}
stage("copy到storage") {
steps {
sh 'rsync -avzP ${WORKSPACE}/android/app/build/outputs/apk/release/*.apk root@192.168.0.6:/opt/android/$Dir/all-version/safettice-`date "+%y-%m-%d-%H:%M"`.apk'
sh 'rsync -avzP ${WORKSPACE}/android/app/build/outputs/apk/release/*.apk root@192.168.0.6:/opt/android/$Dir/safettice.apk'
sh 'rsync -avzP ${WORKSPACE}/safettice.png root@192.168.0.6:/opt/android-image/$Dir/safettice.png'
}
}
stage('set buildDescription') {
steps {
script {
buildDescription "<img src=\"http://192.168.0.6:81/$Dir/safettice.png\" height=\"200\" width=\"200\" /></br><a href = \"http://192.168.0.6:/$Dir/safettice.apk\">点击下载</a>"
}
}
}
}
}
Pipeline-Apk
最新推荐文章于 2024-08-20 10:12:40 发布