3

I have a hudson installed in server's /var/lib/hudson directory. when I access jenkins through URL in my browser,, I see the version 1.411 in the bottom of the page.

Does anybody know how to update Jenkins through command line (CLI). if its possible.

When I go to Manage Jenkins page , it says something like : "New version of Jenkins (1.521) is available for download (changelog)."

I dont feel safe with downloading the new jar and extract that in the server.

Ashish
  • 1,121
  • 2
  • 15
  • 25

3 Answers3

9

Are you referring to the Jenkins CLI, or the CLI on your operating system ? There is no way to update the Jenkins version via the Jenkins CLI.

If you installed Jenkins as a standalone WAR file, all you need to do to upgrade it from the command line is to download the new Jenkins WAR file and replace your current WAR file, then restart Jenkins. It's always a good idea to back up the full contents of your $JENKINS_HOME directory before upgrading.

If you used a native package such as an RPM or DEB, you should use the package manager on your Jenkins server (yum, apt-get etc.) to upgrade Jenkins.

gareth_bowles
  • 20,760
  • 5
  • 52
  • 82
  • I guess , this answers my question. – Ashish Jul 02 '13 at 20:09
  • Thanks a lot, I still have a question about updating GitHub plugin. Everytime I do an update plugin such as GitHub and restart the jenkins, Jenkins start crashing. when I try to access jenkins through URL in my browser, the error page shows up with some exception "class not found jenkins/model jenkins" . and then in order to make jenkins working again , I have to delete the plugin entirely from the plugins directory. I wish someone has an answer for this because I really need to make my github projects available to jenkins for build. Thanks – Ashish Jul 02 '13 at 20:14
  • I'd recommend asking about the plugin problem as a separate question. Take a look in your Jenkins log, too - it may give you some clues. – gareth_bowles Jul 02 '13 at 20:23
  • here is the question, sorry abt tht---> http://stackoverflow.com/questions/17435308/jenkins-crashes-after-installing-github-plugin – Ashish Jul 02 '13 at 20:30
1

Since the accepted answer doesn't tell much about upgrading Jenkins by logging into the server itself, I will add how to do that in a server that uses apt package manager.

After logging into the server, type the following command to list down all the packages that are upgradable.

apt list --upgradable 

You should get an output like this:

Listing... Done
iproute2/bionic-updates 4.15.0-2ubuntu1.3 amd64 [upgradable from: 4.15.0-2ubuntu1.2] jenkins/binary 2.277.1 all [upgradable from: 2.263.4]

If Jenkins is in the output list, just simply run the upgrade with the following command:

apt upgrade jenkins 
Sandun
  • 395
  • 2
  • 10
  • 25
0

Yes we can update the jenkins by CLI. Check which jenkins.rpm is being used

$sudo rpm -q jenkins

in my case it was jenkins-2.119-1.1.noarch. If you don't have jenkins.repo and jenkins key then run following steps

$sudo yum install wget

for installing wget

$sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo

$sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

$sudo yum clean metadata

This will remove unused excessive and old metadata

$sudo yum remove jenkins

it will remove jenkins-2.119-1.1.noarch (old version rpm). Go to jenkins official website page and then copy url of rpm you want

$wget https://get.jenkins.io/redhat/jenkins-2.380-1.1.noarch.rpm

Downloaded required jenkins rpm pkg

$ sudo rpm -i jenkins-2.380-1.1.noarch.rpm

Installed new jenkins rpm

$ sudo rpm -qa jenkins

jenkins-2.380-1.1.noarch

$sudo systemctl enable jenkins

$sudo systemctl start jenkins

here you may get this type of error "Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe"for details" for this we have to update the java version we are using to 11 or latest

$sudo yum install fontconfig java-11-openjdk or

$sudo yum install java-11-openjdk-devel

$sudo update-alternatives --config java

select appropriate version of java

$sudo systemctl start jenkins

jayesh
  • 1