0

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

Peter The Angular Dude
  • 1,112
  • 5
  • 26
  • 53
  • And this server presumably actually runs on port 443? – pvg Dec 13 '15 at 20:21
  • Yes and other ports as well. – Peter The Angular Dude Dec 13 '15 at 20:27
  • Do you have a solution? What's happening is that it's connecting then closing: 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 Any clues how to "keep" it open? – Peter The Angular Dude Dec 13 '15 at 21:13
  • nope, but you could for instance check in the remote end logs that a connection was attempted or look for a reported error. it seems like the remote end just closed the connection on you. you can probably also run an ssh server in a local or remote vm, try to get the basic gruntscp examples working on that and modify them until they look more like what you're trying to do. that also gives you ability to debug and diagnose on both ends – pvg Dec 13 '15 at 21:15
  • PVG thanks and I do have SSH connection points with a shell. Let me try that and I'll get back to you and I'm sorry for the comment above sir. Thank you – Peter The Angular Dude Dec 13 '15 at 21:17
  • hah, no worries. grunt is infuriating and horrible. one other option that might save your a lot of nerves and hair is to just not use grunt for deployment. – pvg Dec 13 '15 at 21:20

0 Answers0