Files
python-cryptbase/Jenkinsfile

94 lines
2.4 KiB
Groovy

pipeline {
agent none
stages {
stage ('Dependency check') {
agent { label 'use' }
steps {
script {
sh '''#!/usr/bin/env bash
source /opt/conda/etc/profile.d/conda.sh
conda create --yes -p "${WORKSPACE}@tmp/${BUILD_NUMBER}" python=3.9
conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}"
pip install --use-deprecated=legacy-resolver -r requirements.dev.txt
pip check
pip list --outdated
conda deactivate
'''
}
}
}
stage('Tests') {
agent { label 'use' }
steps {
script {
script {
sh '''#!/usr/bin/env bash
source /opt/conda/etc/profile.d/conda.sh
conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}"
tox --recreate
conda deactivate
'''
}
}
}
}
stage('Lint') {
agent { label 'use' }
when {
anyOf {
branch 'develop'
branch pattern: "hotfix/.+", comparator: "REGEXP"
}
}
steps {
script {
sh '''#!/usr/bin/env bash
source /opt/conda/etc/profile.d/conda.sh
conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}"
pip install prospector[with_everything]
cd src/; prospector -0
conda deactivate
'''
}
}
}
stage('Sonar') {
agent { label 'use' }
when { branch 'master' }
steps {
script {
sh '''#!/usr/bin/env bash
source /opt/conda/etc/profile.d/conda.sh
conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}"
pip install prospector[with_everything]
cd src; prospector -0 -o pylint:prospector.txt
conda deactivate
'''
def scannerHome = tool name: 'SonarQubeScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation';
withSonarQubeEnv('sonar') {
GIT_COMMIT_HASH = sh (script: "git log -n 1 --pretty=format:'%H'", returnStdout: true)
sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=cryptbase -Dsonar.projectVersion=${GIT_COMMIT_HASH} -Dsonar.python.pylint.reportPaths=prospector.txt -Dsonar.junit.reportsPath=junit-py39.xml -Dsonar.python.coverage.reportPaths=cov-py39.xml -Dsonar.coverage.dtdVerification=false"
}
}
}
}
stage('Cleanup') {
agent { label 'use' }
steps {
dir("${env.WORKSPACE}@tmp") {
deleteDir()
}
}
}
}
post {
always {
mattermostSend "Completed ${env.JOB_NAME} ${env.BUILD_NUMBER}: ${currentBuild.currentResult}"
}
}
}