{"action":"closed","issue":{"url":"https://api.github.com/repos/sue445/jenkins-backup-script/issues/37","repository_url":"https://api.github.com/repos/sue445/jenkins-backup-script","labels_url":"https://api.github.com/repos/sue445/jenkins-backup-script/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/sue445/jenkins-backup-script/issues/37/comments","events_url":"https://api.github.com/repos/sue445/jenkins-backup-script/issues/37/events","html_url":"https://github.com/sue445/jenkins-backup-script/issues/37","id":143541132,"number":37,"title":"Nodes directory is empty","user":{"login":"jquacinella","id":137634,"avatar_url":"https://avatars.githubusercontent.com/u/137634?v=3","gravatar_id":"","url":"https://api.github.com/users/jquacinella","html_url":"https://github.com/jquacinella","followers_url":"https://api.github.com/users/jquacinella/followers","following_url":"https://api.github.com/users/jquacinella/following{/other_user}","gists_url":"https://api.github.com/users/jquacinella/gists{/gist_id}","starred_url":"https://api.github.com/users/jquacinella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jquacinella/subscriptions","organizations_url":"https://api.github.com/users/jquacinella/orgs","repos_url":"https://api.github.com/users/jquacinella/repos","events_url":"https://api.github.com/users/jquacinella/events{/privacy}","received_events_url":"https://api.github.com/users/jquacinella/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-25T16:55:49Z","updated_at":"2016-04-17T15:42:13Z","closed_at":"2016-04-17T15:42:13Z","body":"Build fails since nodes/ dir is empty:\r\n\r\nOutput:\r\n```\r\n+ '[' -d /var/jenkins_home/nodes/ ']'\r\n+ cp -R '/var/jenkins_home/nodes/*' '/var/jenkins_home/jobs/Backups - Daily Job/workspace/tmp/jenkins-backup/nodes'\r\ncp: cannot stat ‘/var/jenkins_home/nodes/*’: No such file or directory\r\nBuild step 'Execute shell' marked build as failure\r\n[ExclusiveBuildWrapper] Canceling Jenkins shutdown mode... \r\nFinished: FAILURE\r\n```\r\n\r\nYou could use an extra conditional to prevent this from happening if dir is empty (http://www.cyberciti.biz/faq/linux-unix-shell-check-if-directory-empty/), like:\r\n\r\n`if [ \"$(ls -A $DIR)\" ]; then`"}}