所以,我正在努力让grunt-scp工作。我和一个庞大的电信公司在一起,我在他们的系统内部,或者在VPN上。我可以直接进入服务器并使用WINSCP。
所以我在这里得到了我的榜样:Grunt SCP Example
现在我的代码:
先决条件:
.ftppass or secret.json. Either will work
//WIN SCP
scp: {
qat2: {
options: {
host: '123.45.678.900',
port: 443,
username: '<%= secret.qat2.username %>',
password: '<%= secret.qat2.password %>'
},
files: [{
cwd: allFiles.srcPath.client,
src: '**/*',
//filter: 'isDirectory',
dest: allFiles.uploadServer + '**/*'
}]
}
},
allFiles.srcPath.client在我的机器文字中:
/var/www/html/app/oauth2/v1
allFiles.uploadServer =与上面相同,但是对于服务器。
loadNpmTasks
grunt.loadNpmTasks('grunt-scp');
现在是grunt注册任务:
//SCP
grunt.registerTask('scpThis', [
'scp:qat2',
'clean:qat2'
], function () {
try {
grunt.task.run([
'scp:qat2',
'clean:qat2'
]);
}
catch (e) {
console.log("SCP Connection failed...", e);
}
console.log("pkg: ", pkg);
console.log("Starting SCP SEQUENCE");
});
CLEAN被召回以清理远程服务器,当我
时我有一个本地人以下是该部分:
clean: {
build: {
src: [ //THIS IS FOR LOCAL Build
'**/*.*',
'/docs/*.*'
//,
//Uncomment out to use
//allFiles.destPath.server + '*.*'
]
},
qat2: { //Thus is for the server when it's called above
options: {
force: true
},
src: allFiles.uploadServer + '**/*'
}
},
结果如下:
Starting SCP SEQUENCE
//JUST SO EVERYONE KNOWS: The server IPs are FAKE and the question in the
//comments below seems like PVG50 thinks they are REAL. Ah, they are not.
//in any case, IF THEY were real and then the REAL IPs do connect and then
//close. Thoughts on this please?
11:54:59 - Running "scp:qat2" (scp) task
11:54:59 - ssh connect 123.45.678.90
11:54:59 - ssh close 123.45.678.90
11:54:59 -
Running "clean:qat2" (clean) task //This didn't clean the server since the connection closed...
>> 0 paths cleaned.
Done, without errors.
Execution Time (2015-12-13 19:54:57 UTC)
11:54:59 - loading tasks 1.5s ████████████████████████████████████ 77%
scp:qat2 441ms ███████████ 22%
Total 2s
这不起作用
这是我对sftp的尝试:
//SFTP - SSH EXEC
sftp: {
deploy: {
command: "sudo su",
auth: {
host: '<%= secret.qat2.ip %>',
port: 443,
authKey: 'key1'
},
files: {
src: allFiles.destPath.client
},
options: {
path: allFiles.uploadServer,
directoryPermissions: parseInt(777, 8),
createDirectories: true
}
}
},
//SFTP DEPLOY
'sftp-deploy': {
build: {//SERVERS GO HERE LIKE BELOW
command: "sudo su",
auth: {
host: '<%= secret.qat2.ip %>',
port: 443,
authKey: 'key1'
},
cache: 'sftpCache.json', //OMIT from Source Control Stores Locally
expand: true,
src: [
allFiles.destPath.client + 'images/{,*/}*.*',
allFiles.destPath.client + 'images/*.jpg',
allFiles.destPath.client + 'images/*.png',
allFiles.destPath.client + 'scripts/config/*.json',
allFiles.destPath.client + 'tmpl/*.js',
allFiles.destPath.client + '*.html',
allFiles.destPath.client + 'views/*.html',
allFiles.destPath.client + 'views/**/*.html',
allFiles.destPath.client + 'favicon.ico',
allFiles.destPath.client + '.htaccess'
],
dest: allFiles.uploadServer,
concurrency: 4,
progress: true
}
},
现在我运行grunt sftpDeployThis
的结果23:21:59 - Running "sftpDeployThis" task
23:21:59 - Starting SFTP SERVER DEPLOYMENT SEQUENCE
23:21:59 - Running "sftp-deploy:build" (sftp-deploy) task
23:21:59 - Warning: /var/www/html/app/oauth2/v1/images/{,*/}*.* is not an existing location Use --force to continue.
23:21:59 -
Aborted due to warnings.
23:21:59 -
Execution Time (2015-12-13 07:21:58 UTC)
23:21:59 - loading tasks 1.4s ███████████████████████████████████████████ 99%
sftp-deploy:build 15ms █ 1%
Total 1.4s
我已经使用咕噜2年了,这个让我难过。
我想做什么:
感谢所有人提供的任何帮助