diff --git a/Jenkinsfile b/Jenkinsfile index 33f20190c1a0480dd04aa46ed129b0e7183a37ac..dc683126a694a55c7db6d08bf3b6a8955ea2b65a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,8 +42,11 @@ pipeline { agent { docker { label 'ci_label' + alwaysPull true // NEXUS_REGISTRY_IP and NEXUS_REGISTRY_PORT are Jenkins global variables - image "${env.NEXUS_REGISTRY_IP}:${env.NEXUS_REGISTRY_PORT}/nrp:${IMG_TAG}" + registryUrl "https://${env.NEXUS_REGISTRY_IP}:${env.NEXUS_REGISTRY_PORT}" + registryCredentialsId 'nexusadmin' + image "nrp:${IMG_TAG}" args '--entrypoint="" -u root --privileged' } } @@ -68,7 +71,15 @@ pipeline { // Checkout main project to GIT_CHECKOUT_DIR dir(env.GIT_CHECKOUT_DIR) { - checkout scm + checkout([ + $class: "GitSCM", + branches: scm.branches, + extensions: [ + [$class: 'CloneOption', noTags: false], + [$class: 'LocalBranch', localBranch: "**"] + ], + userRemoteConfigs: scm.userRemoteConfigs + ]) sh 'chown -R "${USER}" ./' } @@ -84,8 +95,9 @@ pipeline { cloneRepoTopic(env.GAZEBO_ROS_DIR, 'git@bitbucket.org:hbpneurorobotics/gazeborospackages.git', env.TOPIC_BRANCH, env.DEFAULT_BRANCH, '${USER}') cloneRepoTopic(env.EXP_CONTROL_DIR, 'git@bitbucket.org:hbpneurorobotics/experimentcontrol.git', env.TOPIC_BRANCH, env.DEFAULT_BRANCH, '${USER}') cloneRepoTopic(env.CLE_DIR, 'git@bitbucket.org:hbpneurorobotics/cle.git', env.TOPIC_BRANCH, env.DEFAULT_BRANCH, '${USER}') - cloneRepoTopic(env.EXDBACKEND_DIR, 'git@bitbucket.org:hbpneurorobotics/exdbackend.git', env.TOPIC_BRANCH, env.DEFAULT_BRANCH, '${USER}') - + cloneRepoTopic(env.EXDBACKEND_DIR, 'git@bitbucket.org:hbpneurorobotics/exdbackend.git', env.TOPIC_BRANCH, env.DEFAULT_BRANCH, '${USER}') + + sh "git config --global --add safe.directory '*'" } } diff --git a/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/tests/test_version.py b/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/tests/test_version.py new file mode 100644 index 0000000000000000000000000000000000000000..c4609817fa1d08c175c8be48b4f5ff7b6207a64b --- /dev/null +++ b/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/tests/test_version.py @@ -0,0 +1,20 @@ +""" +Unit tests for testing the version value +""" + +import unittest +import hbp_nrp_distributed_nest.version +from unittest.mock import patch + +__author__ = "Viktor Vorobev" + + +class TestVersion(unittest.TestCase): + + def test_version(self): + self.assertRegex(hbp_nrp_distributed_nest.version._get_version(), "^\d+.\d+.\d+") + self.assertRegex(hbp_nrp_distributed_nest.version.VERSION, "^\d+.\d+.\d+") + + @patch('os.getenv', return_value="/non-existing-path") + def test_version_exception(self, mock_getenv): + self.assertRaises(RuntimeError, hbp_nrp_distributed_nest.version._get_version) diff --git a/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/version.py b/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/version.py index d5d3104d2c2a29ea0c5501bda007849b39c99b00..006613be1f6ed150d46e0c0e8c6cd246ee89b433 100644 --- a/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/version.py +++ b/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/version.py @@ -1,2 +1,18 @@ -'''version string - generated by setVersion.sh''' -VERSION = '3.2.1' +'''version string - automatically calculated from the SCM (git)''' +import subprocess +import os +from subprocess import CalledProcessError + +def _get_version(): + try: + version = subprocess.run(['bash', + f'{os.getenv("HBP")}/user-scripts/nrp_get_scm_version.sh', + 'get_scm_version'], + stdout=subprocess.PIPE, check=True).stdout.decode('utf-8') + except CalledProcessError as e: + raise RuntimeError("The SCM version calculation script failed.\ + Expected path: $HBP/user-scripts/nrp_get_scm_version.sh,\ + check its existance.") from e + return version + +VERSION = _get_version()