0

In a Jenkins file, I have the following code:

#!/usr/bin/env groovy
....
def env_prod = 'prod.env'
def entrypoint = "${env.WORKSPACE}

The above is then combined like this:

${env.WORKSPACE}/$env_prod

And it is fed into a python script (through argparse); the Python script looks like:

def get_package_reference_versions(packages, env_path, env_format):
    with open(env_path) as f:
    deps = f.read()
    ....

In my Jenkins logs, I see:

    [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'

Now I am trying to figure out what is inside the js-deployment-cr directory.

Is there a way to print the environment files inside the js-deployment-cr directory?

N.B. I CANNOT MAKE CHANGES IN THE PYTHON SCRIPT, because it sits in a different repository to the bash script. So I need to figure this out in the Jenkins file.

12
  • That sounds more like ksh than bash. In bash, I'd expect you to get a bash: line 1: ${env.WORKSPACE}: bad substitution Commented Jan 26 at 15:17
  • Sorry, above is actually from a Jenkins log, I should have mentioned that. Commented Jan 26 at 15:19
  • It's not too late, you can always edit your question to bring clarifications (and that's always welcome). It still doesn't explain how such a bash script could produce such output in your jenkins logs. It's also not clear to me what exactly you want to be printed and how (a list of file paths? of file names? Or of their contents? How should they be separated?...) Commented Jan 26 at 15:23
  • Thanks for the feedback, I have made things much clearer (I hope!) in the question. Commented Jan 26 at 15:33
  • Are you really asking how to list the contents of a directory? If so, then I think you need more help than just asking that question here. Indeed, if this is a work system you probabl should not have access to perform that task. There are lots of introductory Linux and Unix courses free on the internet.
    – symcbean
    Commented Jan 26 at 15:37

0

You must log in to answer this question.

Browse other questions tagged .