Ubuntu – Coruppted Jenkins need to reinstall

Jenkins

My jenkins looks like corrupted. After installing older version I tried to upgrade. When I tried

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

It was failed to upgrade. Then I removed jenkins using

sudo apt-get remove jenkins

And again I tried to install.It is giving

    Reading package lists... Done
Building dependency tree       
Reading state information... Done
jenkins is already the newest version.
The following packages were automatically installed and are no longer required:
  libjna-java libhttpcore-java libxbean-java libargs4j-java libhttpclient-java
  libplexus-build-api-java libbackport-util-concurrent-java
  libplexus-utils-java libjffi-java libjffi-jni
  libmaven-common-artifact-filters-java libjsr305-java libcommons-jexl-java
  libplexus-bsh-factory-java libplexus-container-default-java
  libganymed-ssh2-java jenkins-cli libplexus-sec-dispatcher-java
  libcommons-net2-java libjsoup-java libmaven2-core-java libplexus-cipher-java
  libjenkins-remoting-java libeasymock-java libplexus-i18n-java
  libmaven-invoker-java libplexus-containers-java libjaffl-java libdoxia-java
  libmaven-dependency-tree-java libmodello-java libplexus-archiver-java
  libconstantine-java libmaven-scm-java libmaven-enforcer-plugin-java
  libplexus-io-java libwagon-java libcommons-vfs-java libanimal-sniffer-java
  libgoogle-collections-java libnetbeans-cvsclient-java
  libmaven-plugin-testing-java libplexus-classworlds-java libitext1-java
  libplexus-interactivity-api-java libcommons-jxpath-java jenkins-common
  libplexus-interpolation-java libclassworlds-java
  libcommons-configuration-java libjnr-posix-java libplexus-ant-factory-java
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 513 not upgraded.

But service jenkins restart command throwing

jenkins: unrecognized service

Even http://localhost:8080/ not working.

I want to install from beginning . Any suggestions?

Edited:

I followed these steps :

sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get install -f && sudo apt-get autoremove

and then same above steps followed to install.

But still same error.Again I tried to remove package using

sudo apt-get remove jenkins && sudo apt-get install jenkins

This is part of output:

The following NEW packages will be installed:
  jenkins
0 upgraded, 1 newly installed, 0 to remove and 268 not upgraded.
Need to get 0 B/61.3 MB of archives.
After this operation, 67.4 MB of additional disk space will be used.
Selecting previously unselected package jenkins.
(Reading database ... 224579 files and directories currently installed.)
Unpacking jenkins (from .../archives/jenkins_1.557_all.deb) ...
Processing triggers for ureadahead ...
Setting up jenkins (1.557) ...

But still service not recognized.

One more thing I noticed is /etc/init.d/jenkins is empty.

Any other way to install same jenkins package?

Best Answer

Well, the package was removed so that is why it is not starting or running. Run sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get install -f && sudo apt-get autoremove In the future take care when installing packages from outside the ubuntu repos. IMO you are better off building from source or using a ppa.

From your description of the problem, your config file was somehow corrupted. simply removing and reinstalling a package will not fix the problem (it rarely does in Linux) because apt-get remove foo removes the libs and binary, but leaves the configuration files in place. When you then install apt-get install foo the config files remain.

To resolve this problem, IMO it is best to purge rather then remove a package (although if you prefer you can edit the config files to modify the behavior of apt-get).

sudo apt-get purge jenkins
sudo apt-get install jenkins

If the problem persists you may need to file a bug report against jenkins.

Related Question