Cannot get grunt-scp, grunt-sftp, grunt----- anything to upload to my server except grunt-ftp

410 views Asked by At

So, I'm struggling here with getting grunt-scp to work. I'm with a huge telecom and I'm internal to their system or at home on VPN. I can ssh into the server and using WINSCP.

So here's where I got my example: Grunt SCP Example

And now my code:

Pre-requisites:

.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 + '**/*'
                }]
        }
    },

The allFiles.srcPath.client is on my machine literal as:

/var/www/html/app/oauth2/v1

The allFiles.uploadServer = the same as above but for the server.

The loadNpmTasks

grunt.loadNpmTasks('grunt-scp');

Now the grunt register task:

//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");
});

The CLEAN is recalled to clean out the remote server, I have a local when I

Here's that section:

 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 + '**/*'

        }
    },

Here's the result:

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

This doesn't work

Here's my attempt with 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
        }
    },

Now the result when I run 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

I've been using grunt for 2 years and this one's got me stumped.

What I want to do:

  1. connect to the server
  2. clean the deploy directory
  3. push the already compiled app from my machine to the server
  4. run the scripts I have, whichever one will work
  5. Receive notifications that DONE WITHOUT ERRORS actually worked
  6. Verify on the server that the files are indeed there with WINSCP (This works fine - viewing the directory I mean.)

Thanks all for any help that can be offered

0

There are 0 answers