0

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.

Edit:

enter image description here

Vineesh TP
  • 7,755
  • 12
  • 66
  • 130

1 Answers1

1

Even though you are specifying the directory, it is possible Python or Bamboo does not have direct access within the confines of your script task.

Have your first task in Bamboo be to Checkout the source code from the linked repository. You can give it a checkout directory name if you want as long as you set this in the working directory step below.

Next, modify your script task with the following changes:

  • Set the interpreter is shell
  • Set the Environment varaiable to be PATH="$PATH:/usr/local/bin" This will allow Bamboo access to the Path variable for Python.
  • Define your working directory from after "XXXXSCRIP-XXXXSCRIP-JOB1". In Bamboo your default working directory will be "XXXXSCRIP-XXXXSCRIP-JOB1". So if you checked out your python code to ProjectName the working directory of the script should simply be ProjectName.
Wesley Rolnick
  • 871
  • 4
  • 11
  • Thank you for the reply. Added the environment variable. Still the same error. – Vineesh TP Jul 25 '19 at 06:36
  • I have updated the question with modified task screenshot. – Vineesh TP Jul 25 '19 at 06:45
  • 1
    @VineeshTP: Something is still wrong with your path. It could either be you need a "./" in front of "/ProjectName/" or you do not need ProjectName at all (Depends on what the working directory looks like after the check out step). Try navigating to your Python file on the Bamboo server with a terminal and verifying the directory there. – Wesley Rolnick Jul 25 '19 at 11:31
  • resolved by navigating the python file directory. Added the direcory /mydirectory – Vineesh TP Aug 30 '19 at 13:19