mschuchard / linter-jenkins

Jenkinsfile lint via declarative linter for pulsar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[CLI and SSH] Linter plugin fails when a ~/.ssh/config exists

gpmayorga opened this issue · comments

After a long troubleshooting session (my Jenkins servers use Github Oauth, so the setup wasn't straight forward) I manage to get this working using "CLI and SSH", the only issue is that jenkins-cli.jar throws an INFO message if a ~/.ssh/config file exists:

guille$ java -jar ~/jenkins-cli.jar -s https://jenkins.paris-squad.com -ssh -user goperez -i ~/.ssh/jenkins-master declarative-linter < /Users/username/Projects/BuildJenkinsfile

Dec 05, 2018 6:31:15 PM org.apache.sshd.client.config.hosts.ConfigFileHostEntryResolver reloadHostConfigEntries
INFO: resolveEffectiveResolver(username@jenkins.myexample.com:2222) loaded 25 entries from /Users/guille/.ssh/config
Jenkinsfile successfully validated.

And it just so happens that your app considers this INFO message as an error and throws an exception:

[Linter] Error running Jenkins Error: Dec 05, 2018 6:36:25 PM org.apache.sshd.client.config.hosts.ConfigFileHostEntryResolver reloadHostConfigEntries
INFO: resolveEffectiveResolver(username@jenkins.myexample.com:2222) loaded 25 entries from /Users/username/.ssh/config
    at ChildProcess.<anonymous> (/Users/guille/.atom/packages/linter-jenkins/node_modules/sb-exec/lib/index.js:41)
    at emitTwo (events.js:126)
    at ChildProcess.emit (events.js:214)
    at maybeClose (internal/child_process.js:925)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209)

I'm assuming this would be the case if Jenkins returns anything but the expected string through stdout. It's an edge corner but it also means the error handling is a little poor, totally worth looking into it (I would if I had more JS experience).

Thank you,

I have seen something similar to this, because I was working on getting the linter working with automatic host authorization. What happens is those "INFO" messages from SSH are being returned as non-zero exit return values, so the underlying sb-exec backend npm treats them as failures. I tried circumventing this by allowing non-zero exit codes, but then errors become ignored, which becomes problematic for debugging.

This issue will likely be helpful when I revisit the related issue I saw. I was going to punt on it indefinitely, but it seems the problem arises in other situations and I can take a fresh look at it.

I doublechecked my notes and actually it is because SSH is outputting that "INFO" statement to stderr and not because of a non-zero return value. Sub that in for my comments above.

Workaround provided in fa76b3d. Please patch in the latest main.js to your local package at ~/.atom/packages, reload Atom, enable the new config option, and see if that fixes the issue for you. Make sure it works in both cases where the Jenkinsfile is valid and invalid.

I tried the new file, but no luck. I reloaded Atom twice just in case. Similar error appears:

/Users/guille/.atom/packages/linter/lib/linter-registry.js:159 [Linter] Error running Jenkins Error: Jan 21, 2019 8:19:45 PM org.apache.sshd.client.config.hosts.ConfigFileHostEntryResolver reloadHostConfigEntries
INFO: resolveEffectiveResolver(goperez@jenkins.paris-squad.com:2222) loaded 25 entries from /Users/guille/.ssh/config
    at ChildProcess.<anonymous> (/Users/guille/.atom/packages/linter-jenkins/node_modules/sb-exec/lib/index.js:41:20)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(anonymous) @ /Users/guille/.atom/packages/linter/lib/linter-registry.js:159

Here's my ~/.ssh/config:

Host jenkins.dev.uts-squad.com
  hostname 192.168.10.8
  ProxyCommand ssh uts-bastion-dev -W %h:%p

Thank you for taking the time to try to solve this

I will put this back on the TODOs. Thanks for providing the config so I can attempt to duplicate this.

I just tested this and verified that Ignore stderr Output bypasses the issue with ssh outputting info and warning to stderr. Instead of the ssh message being thrown to the Atom error display, the linter diagnostic output is displayed as expected.

Sorry I cannot reproduce this when utilizing the fix I implemented for this.

I think I am seeing the same problem. I'm not getting any errors in atom, but I'm not getting any linter output either.

When I enable the debug output and I copy paste the command it is running I get the response I would expect, it is just not translating properly into atom.

I also tried the patch and new option that was discussed, but I saw no difference. Still no error messages.

I am also using a .ssh/config where I've set up a proxyCommand, so it seems like our use cases are very similar.

@mnordsletten You have a different situation since this issue is rooted in sb-exec treating all stderr file descriptor output as an error unless otherwise specified. Please open a new issue for your situation.

Closing due to unable to reproduce and lack of update. Please request a re-open if necessary.