我正在尝试在 Jenkins 上构建 CI/CD 流程。我在 Jenkins 上更新了我的文件,但在某个测试阶段,代码测试失败,但在我的本地机器上没有失败。
Jenkins 上的测试错误显示:
+ python cidr_convert_api/python/tests.py
..E..E
======================================================================
ERROR: test_invalid_mask_to_cidr (__main__.TestStringMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
File "cidr_convert_api/python/tests.py",line 30,in test_invalid_mask_to_cidr
self.assertEqual('Invalid',self.convert.mask_to_cidr('0.0.0.0'))
File "/var/lib/jenkins/workspace/WL_Interview/cidr_convert_api/python/convert.py",line 17,in mask_to_cidr
values = list(map(lambda x: 8 - math.log2(2**8 - int(x)),values))
File "/var/lib/jenkins/workspace/WL_Interview/cidr_convert_api/python/convert.py",in <lambda>
values = list(map(lambda x: 8 - math.log2(2**8 - int(x)),values))
AttributeError: 'module' object has no attribute 'log2'
======================================================================
ERROR: test_valid_mask_to_cidr (__main__.TestStringMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
File "cidr_convert_api/python/tests.py",in test_valid_mask_to_cidr
self.assertEqual('1',self.convert.mask_to_cidr('128.0.0.0'))
File "/var/lib/jenkins/workspace/WL_Interview/cidr_convert_api/python/convert.py",values))
AttributeError: 'module' object has no attribute 'log2'
----------------------------------------------------------------------
Ran 6 tests in 0.000s
FAILED (errors=2)
在我的本地机器上通过的测试如下所示:
Image of passed test on machine
最后,构建的视图如下所示: jenkins dashboard。
我有一个 dockerfile、API 文件和其他中间件,如果您需要其中任何一个以获得更多上下文,请提出请求。
我真的很感激谁能帮忙。谢谢!