Skip to content
Snippets Groups Projects
Commit 57d23d6d authored by Viktor Vorobev's avatar Viktor Vorobev
Browse files

Merged in NRRPLT-8635-scm-versioning (pull request #35)

NRRPLT-8635 scm versioning

Approved-by: Ugo Albanese
Approved-by: Vahid Zolfaghari
parent 4cf50150
No related branches found
No related tags found
No related merge requests found
......@@ -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 '*'"
}
}
......
"""
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)
'''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()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment