diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..d68115df439a8f9e4cc4ba62d79d4c3bddfc71c5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,84 @@ +// make sure the pip cache is accessible +def container_args = "-v ${env.JENKINS_HOME}/.cache:/cache:rw,z -e XDG_CACHE_HOME=/cache" + +pipeline { + agent none + stages { + stage('init') { + agent any + steps { + script { + def matcher = env.GIT_URL =~ /\/(.*)\.git/ + + if(matcher.find()) { + gitProjectId = matcher[0][1]; + } + } + echo gitProjectId + } + } + stage('test') { + parallel { + + stage('test Python 3.6.8 (Centos 7)') { + agent { + docker { + image 'python:3.6.8' + args container_args + } + } + steps { + run_unit_tests('py36') + } + } + + stage('test Python 3.7.6') { + agent { + docker { + image 'python:3.7.6' + args container_args + } + } + steps { + run_unit_tests('py37') + } + } + + stage('test Python 3.8.3') { + agent { + docker { + image 'python:3.8.3' + args container_args + } + } + steps { + run_unit_tests('py38') + } + } + + } + } + stage('SonarQube analysis') { + agent any + steps { + script { + // must match 'Name' from Jenkins 'Global Tool Configuration' + scannerHome = tool 'sonar-scaner'; + } + // must match 'Name' from Jenkins 'Configure System' + withSonarQubeEnv('Project SonarQube') { + sh "${scannerHome}/bin/sonar-scanner -Dproject.settings=./sonar.properties" + } + } + + } + } +} + +void run_unit_tests(tox_env) { + sh 'python -m venv venv' + sh 'venv/bin/pip install tox' + sh "venv/bin/tox -e $tox_env" +} + + diff --git a/sonar.properties b/sonar.properties new file mode 100644 index 0000000000000000000000000000000000000000..4ffb5373154b581449771b0b3e28ff4d37dabc33 --- /dev/null +++ b/sonar.properties @@ -0,0 +1,5 @@ +sonar.projectKey=inventory-provider +sonar.projectName=Inventory Provider +sonar.projectVersion=0.x +sonar.sources=inventory_provider +sonar.python.coverage.reportPaths=coverage.xml