Jenkins 0 files published after build

2019-02-27 09:47发布

问题:

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

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

回答1:

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.