2

I have a Jenkins server setup with two jobs

first job polls the develop branch and builds the project on the jenkins server. i then have another job that polls the production branch this builds this branch on another jenkins slave which is the staging server. This job is configured so that on a successful build it should publish the artefacts over ssh to the production server.

All the SSh keys are setup and the staging server connects to production server but 0 files are transferred

using GIT_SSH to set credentials Bitbucket Repo

using .gitcredentials to set credentials
Checking out Revision 89874cc01a9f669df69817b1049b1ab98ecb19d3 (origin/Production)

SSH: Connecting from host [nginx-php-fastcgi]
SSH: Connecting with configuration [AmazonAWS] ...

SSH: Disconnecting configuration [AmazonAWS] ...
SSH: Transferred 0 file(s)
Finished: SUCCESS

Jenkins is setup to use the workspace on the staging server to deploy files

I checked the staging workspace and files are being built there, just not sent to the prod server. Any suggestions??

i have also tried a different remove prefix as suggested bellow and here Jenkins transferring 0 files using publish over SSH plugin i have also tried a different remove prefix path as suggested

Community
  • 1
  • 1
James Kirkby
  • 1,716
  • 5
  • 24
  • 46
  • I am confused, are you trying to access the files of the same build or another build job? If same build, why are you specifying full filesystem path instead of relying on `${WORKSPACE}` (which you don't need to specify since this is default base directory) – Slav Apr 21 '14 at 14:45
  • Im trying to access the files of that build, Jenkins should build the commit on the staging server then run stress tests the application, once test passed they should be deployed to the production server. I want the production server to only allow public connections over port 80, all other ports are to block all connections apart from port 22 which should only be accessible via the staging server, the staging server is allowed access on a per ip basis, for additional security on the production server. – James Kirkby Apr 21 '14 at 15:05
  • At the moment all ports are open so it shouldn't be a security misconfig I have set the ${WORKSPACE} as the target source files, which is where Jenkins is building the commit on the production server but even then it's not deploying the files – James Kirkby Apr 21 '14 at 15:05
  • I've updated my answer. You should leave the "source files" simply blank if you want all files from the workspace. – Slav Apr 21 '14 at 15:07
  • Jenkins doesnt like that Checking out Revision 89874cc01a9f669df69817b1049b1ab98ecb19d3 (origin/Production) SSH: Connecting from host [nginx-php-fastcgi] SSH: Connecting with configuration [AmazonAWS] ... SSH: Disconnecting configuration [AmazonAWS] ... ERROR: Exception when publishing, exception message [An SSH Transfer Set must not have an empty Source files and an empty Exec command - the transfer set should transfer files, execute a command or do both] Finished: UNSTABLE – James Kirkby Apr 21 '14 at 15:08
  • Sorry, put a `*` then – Slav Apr 21 '14 at 15:10
  • Thanks that does now start to send files over. My project is a drupal build so there should be a shed load of files transferred. but only 18 are being transferred which is all the standard files from the www directory rather than all the directories contained in the webroot – James Kirkby Apr 21 '14 at 15:16
  • To include sub-directories, use `**/*` – Slav Apr 21 '14 at 15:17
  • 1
    Thank you !! i will make sure to acknowledge you in my dissertation! – James Kirkby Apr 21 '14 at 15:39

1 Answers1

2

You should remove /* from the Remove prefix line

Edit:
Your Source files cannot be outside of the job's workspace. If your files are in the root of workspace, just set it to * to transfer all workspace files, or **/* to include subdirectories. Else specify a pattern relative to ${WORKSPACE}.

Even adding a leading / will not escape that, as all it does is append that to workspace, in your case it becomes ${WORKSPACE}/var/www/workspace/opms-staging-server. Even using parent directory ../ will not work. This is for security concerns, else a job configurer could transfer private files off the Jenkins server.

If you need to get files from another job, you need to use Copy Artifacts build step. Tell me if that's your case, and I will explain further.

Slav
  • 27,057
  • 11
  • 80
  • 104
  • I have tried that in response to this question http://stackoverflow.com/questions/22158092/jenkins-transferring-0-files-using-publish-over-ssh-plugin – James Kirkby Apr 21 '14 at 14:16
  • Updated answer: the "source files" part is literally added to the current ${WORKSPACE} location, after stripping parent directory references (`../`) – Slav Apr 21 '14 at 15:08