Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

python: can't open file - Bamboo

Vineesh July 24, 2019

 

I have configured a task as check out source code from Bit-Bucket and it is working fine.

As per some comments I can see the below lines is working fine.

/usr/bin/python <<EOF
print "Hello, World!"
EOF

 

I an trying to run my python file from the check out source code.

As per the documentation got the current working directory from the below code,

${bamboo.working.directory}

Got the result :
/opt/atlassian/atlassian-bamboo-home-6.4.1/xml-data/build-dir/XXXXSCRIP-XXXXSCRIP-JOB1

 

and My repository path is

ProjectName/app.py

 

Added an script task and given the below as inline comments,

/usr/bin/python /opt/atlassian/atlassian-bamboo-home-6.4.1/xml-data/build-dir/XXXXSCRIP-XXXXSCRIP-JOB1/ProjectName/app.py

 

But, failed to execute. Please see the below error message.

python: can't open file '/opt/atlassian/atlassian-bamboo-home-6.4.1/xml-data/build-dir/XXXXSCRIP-XXXXSCRIP-JOB1/ProjectName/app.py': [Errno 2] No such file or directory

 

How do I solve this issue.

 

1 answer

0 votes
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 26, 2019

Hi @Vineesh,

That type of error can have two main causes:

  1. The file is not there.
  2. The file somehow has restricted permissions.

How to mitigate them?

  1. Check if the file is there or add an extra command in your build just to check that.
    You can navigate to that directory in the terminal after the build as well.
    Make sure you are checking the right agent in case you are running this build in a remote agent.
  2. If the file is there, check the permissions to make sure the python command can access the file.

If not of those options are the case, try to navigate to the working directory from the terminal and check if you can run the script using the exact same command Bamboo is using.

Let me know how it goes.

Bharath_Venkat_Rajan July 31, 2019

@Vineesh Did you find a solution for this?

@Daniel Santos What if I do not have terminal access to the file? Like, I am using Bamboo in a corporate environment, I do not have access to it.

Bharath_Venkat_Rajan August 1, 2019

Found it. It is because of User Permissions.

In case someone has the same problem of not having terminal access. Just Do:

1. Script Task and write Inline, "chmod XXX <filename>".

2. Create another Script Task and call the file there. 

Like Daniel Santos likes this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 1, 2019

Hi @Bharath_Venkat_Rajan,

I'm sorry, I didn't have time to answer your message.
Yes, I would say that any time you need terminal you can use a script task for that.

I'm glad you found your own way. =]

Like Bharath_Venkat_Rajan likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events