Contain:
- Jenkins: 代码持续交互生产平台
- Gitlab: 代码托管平台
- SonarQube: 代码质量扫描平台
- Sentry: 错误日志管理平台
- Yapi: 文档管理平台
- Docker
Jenkins: 配置
- 项目:dacheadmin后台java
- 源码管理:Git 、url 、选择分支
- Build根目录POM文件
- post steps:文件上传/发布的服务器
- 项目:dacheadmin后台vue
- Add timestamps to the Console Output
- Provide Node & npm bin/ folder to PATH
- 选择nodejs版本
构建操作
cd ./frontWeb
node -v
npm install -g yarn --registry=https://registry.npm.taobao.org
yarn -v
yarn install
yarn lint
yarn build
cd ./dist/
tar -zcvf dist.tar.gz *
- 项目:mqtt项目同1
- 项目:sfc同上
- 项目:php
- 项目:安卓
- 项目:微信小程序ci
另一种方式:使用pipeline script
pipeline {
agent any
// 环境变量
environment {
GIT_USER_NAME = 'ljie'
GIT_USER_EMAIL = 'liujie@guoshikeji.onaliyun.com'
GIT_ADDRESS = 'http://ljie:456789123qaz@192.168.0.70:10080/guoshi/wxminiproject.git'
BRANCH_NAME = 'Bike'
}
// 拉取git代码
stages {
stage('git pull') {
steps {
git branch: 'Bike', credentialsId: '3fbceb89-c153-4179-8663-c022ea106dfa', url: 'http://192.168.0.70:10080/guoshi/wxminiproject.git'
}
}
// 询问当前版本信息
stage('inquirer version') {
steps {
script {
// 读取版本信息
def versionJson = readJSON file: './version.config.json', text: ''
// 设置问题描述
def userInput = input(
id: 'versionInput',
message: '请设置版本信息',
parameters: [
[defaultValue: versionJson.version, description: '设置版本号', name: 'VERSION', $class: 'TextParameterDefinition'],
[defaultValue: 'jenkins CI的上传试用版为: ' + new Date().format('yyyy-MM-dd HH:mm:ss'), description: '设置版本描述(please use english)', name: 'VERSIONDESC', $class: 'TextParameterDefinition']
]
)
// 设置全局变量
env.VERSION = userInput.VERSION;
env.VERSIONDESC = userInput.VERSIONDESC;
// 重写本地版本文件(为后续进行版本提交做准备)
writeJSON file: './version.config.json', json: [version: env.VERSION, versionDesc: env.VERSIONDESC], pretty: 4;
}
}
}
// 构建
stage('build') {
steps {
nodejs('NodeJS 14.3.0') {
sh "npm install"
sh "npm run build"
}
}
}
// 推送版本信息到git仓库
stage('push version2git') {
steps {
sh "git config --local user.name ${GIT_USER_NAME} && git config --local user.email ${GIT_USER_EMAIL}"
sh "git add version.config.json"
sh "git commit -m 'docs: 更改版本号为${VERSION}'"
sh "git checkout ${BRANCH_NAME}"
sh "git push ${GIT_ADDRESS}"
script {
buildDescription '<img src ="./${BUILD_NUMBER}/execution/node/3/ws/destination.jpg" height="100" width="100">'
}
}
}
}
}
选项:使用 Groovy 沙盒 yes