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

Pipelines Local files location

Adam Woloszyn October 24, 2016

Greetings all,

I am relatively experienced with Jenkins build scripts and use bash scripts for these. My problem I'm facing right now is that I have no clue where the local files are from my project. In Jenkins it is in {WORKSPACE} variable. I guess I'm failing to grasp where my project files are? I try to reference a .sh script that is in the root of my project/repository, but when I try to run it with several different options, I'm getting permission denied or if I try to run the command as a step in the pipeline.yml, it isn't running as expected.

For example, if I have a zip.sh file that contains a simple zip command to zip up my projects, if I do:

- ./zip.sh

it says permission denied. 

If I try to zip it like:

- zip -r /build/deploy.zip . -i /src
 

I get an empty zip file, even though in my root folder the /src directory has contents. But if I were to ls -lsa, I can clearly see that "src" doesn't exist.

What am I missing? 

I realize this might be a dumb question, but hoping someone can help out a noob to Pipelines!

Adam

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 24, 2016

The initial working directory of your pipeline script should always be the directory containing your project files. The absolute path for that directory is also available in the BITBUCKET_CLONE_DIR environment variable.

If you're getting errors running a script that's in your project you may want to check the permissions, especially the "execute" permission. Try something like this to find out what's going wrong:

- ls -al
- chmod 755 ./zip.sh
- ls -al
- ./zip.sh
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 24, 2016

BTW if the problem is indeed the execute permission then you should look into enabling the execute bit against the file within your repository (I believe that both git and mercurial support doing this). If it's stored correctly in your repository then you shouldn't need to chmod it in your Pipelines script.

Adam Woloszyn October 25, 2016

Hi Steven,

I appreciate the prompt response! I'm starting to understand the file structure a bit more. Essentially we start in the cloned environment folder (did a "pwd" to find out full path - should have done that sooner), and then if you were to "cd /" you end up in the root of the server. 

I don't see that documented anywhere, and realizing it was a silly mistake to not find sooner. I'm newer to SSH/Linux so I don't always think of the best debugging processes.

Regarding your comment about enabling the execute within the repo, are you just suggesting my file permission is wrong before committing?

Thanks much!

Adam

Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 25, 2016

I'm not sure it's as simple as just enabling the execute bit on the file before committing. Some quick googling seems to suggest there could be other factors involved. For example here's a discussion of the issue in git: http://stackoverflow.com/questions/14267441/automatically-apply-git-update-index-chmodx-to-executable-files

TAGS
AUG Leaders

Atlassian Community Events