|
| 1 | +node { |
| 2 | + properties([ |
| 3 | + disableConcurrentBuilds() |
| 4 | + ]) |
| 5 | + stage('Checkout SCM') { |
| 6 | + checkout scm |
| 7 | + } |
| 8 | + stage('Agent Setup') { |
| 9 | + docker.withRegistry('http://gitea.lan:3000', 'gitea') { |
| 10 | + customImage = docker.build( |
| 11 | + "root/jenkins-python:latest", |
| 12 | + "-f .devcontainer/Dockerfile ./") |
| 13 | + customImage.push() // push custom image to the own registry |
| 14 | + } |
| 15 | + } |
| 16 | + customImage.inside('--net="jenkins_default"') { // required for accessing the Gitea server |
| 17 | + stage('Cleanup') { |
| 18 | + sh 'rm -rf dist build' |
| 19 | + } |
| 20 | + stage('Build documentation') { |
| 21 | + sh './tools/build-docs.sh' |
| 22 | + archiveArtifacts( |
| 23 | + artifacts: 'build/html/**', |
| 24 | + onlyIfSuccessful: true |
| 25 | + ) |
| 26 | + publishHTML([ |
| 27 | + allowMissing: false, |
| 28 | + alwaysLinkToLastBuild: false, |
| 29 | + keepAll: false, |
| 30 | + reportDir: 'build/html/', |
| 31 | + reportFiles: 'index.html', |
| 32 | + reportName: 'Documentation', |
| 33 | + reportTitles: '', |
| 34 | + useWrapperFileDirectly: true |
| 35 | + ]) |
| 36 | + } |
| 37 | + stage('Build Python package') { |
| 38 | + sh './tools/build-package.sh' |
| 39 | + archiveArtifacts( |
| 40 | + artifacts: 'dist/*.whl', |
| 41 | + onlyIfSuccessful: true |
| 42 | + ) |
| 43 | + } |
| 44 | + stage('Static code analysis') { |
| 45 | + warnError('lint issues found') { |
| 46 | + sh './tools/lint-package.sh' |
| 47 | + } |
| 48 | + recordIssues( |
| 49 | + sourceCodeRetention: 'LAST_BUILD', |
| 50 | + tools: [ |
| 51 | + taskScanner( |
| 52 | + highTags: 'FIXME', |
| 53 | + includePattern: 'src/**/*.py', |
| 54 | + lowTags: 'HACK', |
| 55 | + normalTags: 'TODO' |
| 56 | + ), |
| 57 | + flake8(pattern: 'build/flake8.txt'), |
| 58 | + pyLint(pattern: 'build/pylint.txt'), |
| 59 | + myPy(pattern: 'build/mypy.txt'), |
| 60 | + pyLint(pattern: 'build/ruff.txt', id: 'ruff', name: 'Ruff') |
| 61 | + ] |
| 62 | + ) |
| 63 | + } |
| 64 | + stage('Test Python package') { |
| 65 | + sh './tools/test-package.sh' |
| 66 | + junit( |
| 67 | + testResults: 'build/test-report.xml' |
| 68 | + ) |
| 69 | + recordCoverage( |
| 70 | + tools: [ |
| 71 | + [parser: 'JUNIT', pattern: 'build/test-report.xml'], |
| 72 | + [parser: 'COBERTURA', pattern: 'build/test-coverage.xml'] |
| 73 | + ] |
| 74 | + ) |
| 75 | + } |
| 76 | + stage('Deploy Python package') { |
| 77 | + //withEnv([ |
| 78 | + // 'TWINE_REPOSITORY="gitea"' |
| 79 | + //]) { |
| 80 | + // sh 'twine upload --config-file .pypirc dist/*' |
| 81 | + //} |
| 82 | + withEnv([ |
| 83 | + 'UV_PUBLISH_URL=http://gitea.lan:3000/api/packages/root/pypi' |
| 84 | + ]) { |
| 85 | + withCredentials([ |
| 86 | + usernamePassword( |
| 87 | + credentialsId: 'gitea', |
| 88 | + usernameVariable: 'UV_PUBLISH_USERNAME', |
| 89 | + passwordVariable: 'UV_PUBLISH_PASSWORD' |
| 90 | + ) |
| 91 | + ]) { |
| 92 | + sh './tools/deploy-package.sh' |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | +} |
0 commit comments