Could anyone point me towards a tutorial that could give me some guidance on how to complete the task Install Packages Using a Jenkins Job? I have tried several configurations (and plugins) and nothing that I have tried is working.
Thanks in advance to anyone who can help:-)
ps. Here are the steps that I attempted via my most recent attempt:
# install plugin + update other plugins
SSH Build Wrappers
Jenkins --> Manage Jenkins --> Credentials --> add credentials
# Add username and password credentials from each app server
Jenkins --> Manage Jenkins --> configure system --> go to section ( ssh remote hosts) -- add three hostnames + port 22
# add each user to sudo user file
ssh tony@stapp01 Ir0nM@n
sudo visudo
# add
tony ALL=(ALL) NOPASSWD: ALL
ssh steve@stapp02 Am3ric@
sudo visudo
# add
steve ALL=(ALL) NOPASSWD: ALL
ssh banner@stapp03 BigGr33n
sudo visudo
# add
banner ALL=(ALL) NOPASSWD: ALL
# Create a freestyle job
# add build step => execute shell script via ssh
# choose host/ssh site for each host => note: UI sticks at 1st attempt
# add script to each host
sudo yum -y install epel-release yum-utils
sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-71.rpm
sudo yum-config-manager --enable remi-php71
sudo yum -y install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
# install httpd
sudo yum -y update httpd
sudo yum -y install httpd
systemctl start httpd
# configure apache and restart the server
sudo sed -i "s/80/8086/g" /etc/httpd/conf/httpd.conf
sudo systemctl restart httpd
# end script
At this point I am getting an error and my job fails to build:
....build failed
Exception:java.net.ConnectException: Connection timed out (Connection timed out)
Started by user Admin User
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/httpd-php
[SSH] commands:
# Install Java
sudo yum update
sudo yum install openjdk-8-dbg
java -version
# install on each server via build => add build step => execute shell script via ssh
# choose host/ssh site for each host => note: UI sticks
sudo yum -y install epel-release yum-utils
sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-72.rpm
sudo yum-config-manager --enable remi-php72
sudo yum -y install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
## install httpd
sudo yum -y update httpd
sudo yum -y install httpd
systemctl start httpd
# configure apache and reload the server
sudo sed '0,/80/{s/80/3004/}' /etc/httpd/conf/httpd.conf
sudo systemctl restart httpd
…which still results in an error/timeout:
[SSH] executing...
[SSH] Exception:java.net.ConnectException: Connection timed out (Connection timed out)
com.jcraft.jsch.JSchException: java.net.ConnectException: Connection timed out (Connection timed out)
at com.jcraft.jsch.Util.createSocket(Util.java:349)
at com.jcraft.jsch.Session.connect(Session.java:215)
at org.jvnet.hudson.plugins.CredentialsSSHSite.createSession(CredentialsSSHSite.java:132)
at org.jvnet.hudson.plugins.CredentialsSSHSite.executeCommand(CredentialsSSHSite.java:208)
at org.jvnet.hudson.plugins.SSHBuilder.perform(SSHBuilder.java:104)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1894)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:428)
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at com.jcraft.jsch.Util.createSocket(Util.java:343)
... 13 more
Build step 'Execute shell script on remote host using ssh' marked build as failure
Finished: FAILURE
I also noticed that I am not able to ssh into the jenkins server from jump host via ssh root@jenkins with the password S3curePass.
I have taken the exact same steps as the link to the video link that I sent you . The only thing that is different this time around is the addition of -y in the first two commands + I moved -y to the end of each command.
@juliettet, use hostname stapp01 instead of stapp01.stratos.xfusioncorp.com, then try it again and make sure to click on check connection to check the status.
…weird…because I just assumed that the zero would not be needed here…because the task (this time) was not asking for .1 or .2 , etc…
I don’t mean to be a pain, but If that is all that caused the task to fail this time, could I please get a pass on this one? Everything was working and the job ran just fine.
You are right about the line sudo yum-config-manager --enable remi-php7 being the one that is incorrect. I have also added the comment in your review along with some guidance on the task. Have a look: Task Review
All steps that I had taken previously (ie., prior to running the job several times) remain the same:
# install plugin + update other plugins
SSH Build Wrappers
Jenkins --> Manage Jenkins --> Credentials --> add credentials
# Add username and pass to the three app servers
tony Ir0nM@n
steve Am3ric@
banner BigGr33n
# Jenkins --> Manage Jenkins --> configure system --> go to section ( ssh remote hosts) -- add three hostnames + port 22
stapp01
stapp02
stapp03
# add each user to sudo user file on each app server after adding credentials via Jenkins UI
# thor password => mjolnir123
# add @ end
ssh tony@stapp01 Ir0nM@n
sudo visudo
# add
tony ALL=(ALL) NOPASSWD: ALL
ssh steve@stapp02 Am3ric@
sudo visudo
# add
steve ALL=(ALL) NOPASSWD: ALL
ssh banner@stapp03 BigGr33n
# add
sudo visudo
banner ALL=(ALL) NOPASSWD: ALL
Ah! Now that certainly looks like a validation error. The PHPInfo page is also showing Apache response from stapp03. Interesting to see the response from KKE team.