在 Jenkins 文件中,我有以下代码:
#!/usr/bin/env groovy
....
def env_prod = 'prod.env'
def entrypoint = "${env.WORKSPACE}
然后将上面的内容组合起来如下:
${env.WORKSPACE}/$env_prod
并将其输入到 python 脚本中(通过argparse
); Python 脚本如下所示:
def get_package_reference_versions(packages, env_path, env_format):
with open(env_path) as f:
deps = f.read()
....
在我的 Jenkins 日志中,我看到:
[2024-01-25T13:39:41.780Z] File "/opt/bmll/miniconda/lib/python3.11/site-packages/something/deployment.py", line 421, in get_package_reference_versions
[2024-01-25T13:39:41.780Z] with open(env_path) as f:
[2024-01-25T13:39:41.780Z] ^^^^^^^^^^^^^^
[2024-01-25T13:39:41.780Z] FileNotFoundError: [Errno 2] No such file or directory: '/home/ec2-user/jenkins/workspace/pipeline-deployments/js-deployment-cr/prod.env'
现在我想弄清楚js-deployment-cr
目录里面有什么。
有没有办法打印js-deployment-cr
目录内的环境文件?
注意,我无法更改 PYTHON 脚本,因为它位于与 bash 脚本不同的存储库中。所以我需要在 Jenkins 文件中解决这个问题。