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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

python: can't open file - Bamboo

 

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

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.

@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.

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

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
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

587 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you