Troubleshooting Jenkins (Two Different Problems)

Problem scenario:  You are in the Jenkins master web UI and are trying to configure a Jenkins node (previously known as a slave) instance.  You entered the correct hostname, username and password.  You get this error:

"ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins.
java.lang.IllegalStateException: Connection is not established!"

Solution:  Instead of using the hostname of the Jenkins node (previously known as a slave) server, use its IP address.

================

Problem scenario:  You installed a new Jenkins instance.  When you go to the IP address over port 8080 in a web browser, you get a blank white screen.

Solution:  Go to Internet Explorer's tools (click the gear symbol if that is the version you have) and go to Options.  Go to the Security tab.  At the top, click the "Trusted Sites" icon.  Click "Sites."  Enter "http://x.x.x.x" with no quotes and replace x.x.x.x with the IP address of Jenkins.  Click Add. Click Close. Click Ok.  Now refresh your web browser.  You should be able to go to Jenkins' UI.

How Do You Install libyaml on a Red Hat Derivative of Linux?

Problem scenario
You are using a RedHat derivative of Linux.  You get an error about libyaml not being installed (e.g., when a dependency of Suricata is unmet).  You tried to install libyaml-devel, but it did not work.  What should you do?

Solution for RHEL
If you are using RedHat run these two commands:

sudo yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
sudo yum -y install libyaml-devel

Solution for CentOS/Fedora

If you are using CentOS or Fedora, go here to get the package you need.

Troubleshooting and an FYI Regarding OpenSSH

Problem scenario #1
You try to SSH to a Windows server with OpenSSH.  You get "Permission Denied."
Solution
Go to the Windows server.  Go to Server Manager -> Tools -> Computer Management -> Users and Groups.  Double click on the user you are trying with.  Uncheck "User must change password at next log on."  This setting will not allow an SSH connection to happen.

Problem scenario #2
ssh-agent service is running on a Windows server with OpenSSH.  From a Linux sever you use this command: nmap -p 22 x.x.x.x #where x.x.x.x is the IP address of the Windows server.  You find that the port is closed (but not filtered).  You cannot SSH to the Windows server.  What is wrong?
Solution
From a PowerShell prompt, run this: start-service sshd
Now port 22 will show as open if you try the nmap command again.  Now you should be able to ssh to the Windows server.

FYI
These directions have a variation of this step of running "start-service sshd" as optional.  It is not an optional step.

How Do You Create an RSA Private/Public Key Pair with OpenSSH in Windows?

Problem scenario
You have OpenSSH installed on a Windows machine.  You are in a PowerShell prompt as Administrator in the directory where the ssh-keygen.exe file is.  You run this:  .\ssh-keygen.exe -t rsa
You get "Generating public/private rsa key pair."  No new prompt appears.  It hangs (or stalls) for a long time.  You wait, and find that it is essentially frozen.  You control-c to interrupt it and move on.

You are in a PowerShell prompt as Administrator in the directory where the ssh-keygen.exe file is.  You run this:  .\ssh-keygen.exe -t rsa -f C:\\Program Files\\OpenSSH\\Openssh-Win64\\newfile
No new prompt appears.  It hangs (or stalls) for a long time.  You wait, and find that it is essentially frozen.  You control-c to interrupt it and move on.

How do you generate a public/private rsa key pair?

Possible Solution #1
Open a cmd prompt. You do not need to do it as Administrator.  cd to the directory where ssh-keygen.exe is.  Use this command ssh-keygen -t rsa (with no .exe).  This creates a private/public key pair.

Alternative solution #2
Open a PowerShell prompt but not as administrator. Run this command: ssh-keygen -t rsa

Two Error Messages when Installing Gems On Linux

Problem scenario:  You are trying to use gem install, but you get an error like this:
"usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h"

Solution:  Install ruby-devel.  For RedHat deriviatives, you can find the rpm here.

=====================================================================================

Problem scenario:  You are running gem install *.gem, and you get 'ERROR: While executing gem ...
(Net::HTTPServerException) 407 "Proxy Authentication Required"'

Potential Solutions:  The server's Internet connection seems to be somewhat working (but not completely and not completely broken either).  Change your proxy settings.  Your proxy seems to be causing an issue.  It could potentially help to disable the proxy to eliminate Internet access.  It may help to reboot the server that you ran the gem install command on.

Using a rubyntlm script (http.rb), you get “connection refused.”

Problem scenario:  You modify this script to have a hostname, username, and password of a Windows server with IIS installed.  You add a "puts line" stanza on line 32 for debugging.  You try to run the script with ruby http.rb, but you get "connection refused."  

Possible solutions:  If you changed the port stanza in the http.rb file from 80, make sure there is no firewall blocking the port in the path to the Windows server.  Some port numbers will not be accessible by default on your Windows servers.  Assuming you leave the port to be assigned to 80, make sure there is nothing blocking it on the network or on the target Windows server.

Rubyntlm: Communication from a Linux Server to a Windows Server

Problem scenario:  You modify this script to have a hostname, username, and password of a Windows server on your network.  You add a "puts line" stanza on line 32.

You run the script but you get a message like this: "HTTP/1.1 404 Not Found error. "

Solution:  Make sure that the Windows server has IIS installed, make sure the server name you entered was correct, and make sure the Windows server is turned on.

This Command “gem install contint.gem” Hangs Forever

Problem scenario:  You are running gem install *.gem and it hangs.  This stalling appears to be a freeze.  You wait several minutes and nothing happens.  You are waiting for a message or a new prompt.

Solution:  Control-C to get out of it.  Try it again with the "-V" flag like this:

gem install contInt.gem -V

# This time be patient.  Sometimes these commands can take more than 10 minutes to return a message.  The -V flag will provide messages (or more detailed messages) as to the problem you are experiencing.  The -V flag and be placed immediately after the "gem install " or at the very end.  The -V flag is interchangeable with the "--verbose" flag.

Unexpected PowerShell Closures and Controlling the Flow of PowerShell Scripts

Problem scenario:  You PowerShell or PowerCLI window keeps exiting automatically when you run a script.  You find that RAM and CPU are not constrained.  
Root cause: Human error.
Solution:  Look for the "exit" or the "Exit-Pssession" commands.  These can close PowerShell's ISE or PowerCLI.  You may need to eliminate these commands or use a different keyword.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Problem scenario:  You want to use a for-each loop in PowerShell, you do not want the script to cause the interactive PowerShell window to close, and you want the action portion (in braces {}) to run only once.  What do you do if you do not want to re-write the function to use an "if" or a "while" loop?

Solution:  Use the "break" or "return" key word as the last line in the action clause.

foreach ($cont in $integration) {
   write-host $cont
   return  # or break
}

Return will return the control of the PowerShell interpreter to the previous location before entering the foreach loop.  This is particularly significant when you have functions.  Break can be called with an accompanying label.  For example,
this code would not just interrupt the foreach clause but the PowerShell interpreter would start parsing the ":contInt" section of code:

:contInt if ($foo -eq 289) {
     while ($foo < 505) {
        foreach ($cont in $integration) {
           write-host $cont
           Break :contInt    
         }
      }
}

In the future we want to re-write these directions to use write-verbose instead of write-host. We want to warn people that write-verbose is recommended instead of write-host (according to this posting).

How do you install Jenkins on a RedHat Linux server without an Internet connection?

Problem Scenario 
(If you have an internet connection, see this posting.)  In trying to install the different .rpms (e.g., on CentOS/RHEL/Fedora) for Jenkins you get errors.

For example, here is one command you might try:
yum localinstall springframework-aop-3.2.15-3.fc24.noarch.rpm

This above command may result in an error like this:
"Requires: mvn(org.springframework:spring-beans) = 3.2.15.RELEASE ... Requires: mvn(org.springframework:spring-core) = 3.2.15.RELEASE"

Here is another command you might try: 
yum localinstall jenkins-instance-identity-1.4-5.fc24.noarch
You might see an error like this:
"Requires: mvn(org.bouncycastle:bcpkix-jdk15on)"

To summarize the problem there are numerous dependencies. Installing Jenkins piece-by-piece is tedious.  How do you install Jenkins without internet access?

Solution
Get an .rpm file from this link: http://pkg.jenkins-ci.org/redhat-stable/ 
One of the files will allow for offline (or standalone) installations.

If you need assistance installing plugins without internet access, see this posting.