1.java
Build a Java app with Maven
2.node.js
Build a Node.js and React app with npm
3.python
Build a Python app with PyInstaller
分类 工具
版本控制工具 GitLab + Git
流水线 Jenkins Pipeline
依赖管理 pip3 + venv + requirements.txt
单元测试 nosetests
测试覆盖率检查 coverage + Jenkins Cobertura插件
代码质量分析 pylint + Jenkins Warnings插件
应用打包 pyinstaller
agent {label 'centos-python3'}
options {
// Keep max num of recent builds
buildDiscarder(logRotator(numToKeepStr: "15"))
// Add timestamps on console output
timestamps()
// Set GitLab connection
gitLabConnection('GitlabAccess')
// Disable concurrent builds
disableConcurrentBuilds()
}
stage('Initialize') {
steps { sh "env" sh "pwd && ls -ltra" cleanWs() sh "pwd && ls -ltra" }
}
//拉取代码
stage('Checkout') {
steps {
git branch: "${GIT_REPO_BRANCH}", credentialsId: "${GIT_CREDENTIALS_ID}", url: "${GIT_REPO_URL}"
}
}
stage('Prepare Build Env') {
steps {
sh """
python3 --version
python3 -m venv .venv
. .venv/bin/activate
pip3 install wheel
pip3 install nose
pip3 install coverage
pip3 install pylint
pip3 install -r requirements.txt
pip3 list
"""
}
}
stage('Unit Test') {
steps {
echo "Run unit test and coverage check"
sh """
. .venv/bin/activate
nosetests -v --with-xunit --xunit-file=${UNIT_TEST_REPORT} --with-coverage --cover-xml --cover-xml-file="${COVERAGE_REPORT}" --cover-package=${COVER_PACKAGE} --cover-erase
"""
}
post {
always {
echo "Archive test results"
junit allowEmptyResults: true, testResults: "${UNIT_TEST_REPORT}"
// Requires Cobertura plugin to archive and display converage report
// https://wiki.jenkins.io/display/JENKINS/Cobertura+Plugin
echo "Archive coverage report"
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: "${COVERAGE_REPORT}", failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false
}
}
}
//
stage('Packaging') {
steps {
echo "Run packaging Python program"
// Requires to run pyinstaller in each kind of machine
script {
PACKAGE_NAME = "${PACKAGE_ID}"
if ("${params.PACKAGE_VERSION}" != "") {
PACKAGE_NAME = "${PACKAGE_NAME}-${params.PACKAGE_VERSION}"
}
PACKAGE_PATH = "./dist/${PACKAGE_NAME}"
}
sh """
. .venv/bin/activate
pip3 install pyinstaller
pyinstaller ${ENTRYPOINT_SCRIPT} --onefile --name ${PACKAGE_NAME}
pwd && ls -ltra
echo "Package: ${PACKAGE_PATH}"
du -sh ${PACKAGE_PATH}
sha256sum ${PACKAGE_PATH}
"""
}
}
4.net在windows上
浙公网安备 33010602011771号