Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send build artifacts over SSH - could not create directory

Tags:

git

ssh

jenkins

I am trying to workout an automation process of pushing changes from jenkins to aws. The problem seems to be that within the GIT repo, i have 2 folders, one is docroot and the other is database. I need the docroot to go into the /var/www/html and database should be ignored for now.

As a trial run, i am trying the following settings:

Settings 1:

Post-build Actions

Under transfer set

Source files: **/*
Remove prefix: empty
Remote directory: empty
Exec command: pwd

Result: ERROR: Exception when publishing, exception message [Could not create or change to directory. Directory [database]] Build step 'Send build artifacts over SSH' changed build result to UNSTABLE Finished: UNSTABLE

Settings 2:

Post-build Actions

Under transfer set

Source files: **/*
Remove prefix: empty
Remote directory: /var/www/html
Exec command: pwd

Result: ERROR: Exception when publishing, exception message [Could not create or change to directory. Directory [var]] Build step 'Send build artifacts over SSH' changed build result to UNSTABLE Finished: UNSTABLE

All the errors seem to be revolving around creation of a directory - but i dont need to create one...

like image 667
Sophie Rhodes Avatar asked Jul 23 '16 17:07

Sophie Rhodes


1 Answers

If the plugin you are using for this step is Publish Over SSH Plugin which seems to be the case the first point of call would be to enable verbose output in the console. For this option to appear you have to click on the Advanced... button under the drop down with server names and you should see something like this:

Enabling verbose output

Once you have done that instead of a mere:

ERROR: Exception when publishing, exception message [Could not create or change to directory. Directory [var]]
Build step 'Send files or execute commands over SSH' changed build result to UNSTABLE

you may see something like this:

SSH: Connecting from host [some.host]
SSH: Connecting with configuration [Some Configuration] ...
SSH: Creating session: username [user], hostname [x.x.x.x], port [22]
SSH: Connecting session ...
...
SSH: cd [/var/lib/module/]
SSH: OK
SSH: mkdir [var]
SSH: FAILED: Message [Permission denied]

This should give you a clue of what may be wrong.

In your case you are not explicitly creating any directory but if you toggle the help tip for Remote directory field you will see this:

Optional destination folder.

This folder will be below the one in the global configuration, if present.
The folder will be created if does not exist.

This would indicate that the location you try to pwd in does not exist and the plugin is helpfully trying to create it for you but your user has no permissions to do so.

While the user permissions may be a problem, if you are certain that the directory exists and none should be created then check the global settings in:

Manage Jenkins -> Configure System -> Publish over SSH

and take a look at the Remote Directory field:

enter image description here

Let's say there is /home/sophie specified there then the plugin will try to send your files to /home/sophie/var/www/html which is not what you want.

like image 161
Johnny Baloney Avatar answered Sep 20 '22 02:09

Johnny Baloney