Installation in Linux

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

You can verify successful installation by checking 127.0.0.1:8080 with the web-browser.

Upgrade

$ sudo apt-get update
$ sudo apt-get install jenkins

Configuration

Port

  • The default port is 8080.
  • If you wanna change the port, replace 8080 with 8082(new port) in /etc/init.d/jenkins and /etc/default/jenkins
  • Restart the service.
$ sudo service jenkins restart

You can verify successful configuration by checking 127.0.0.1:8082 with the web-browser.

Default Password

  • the default account is admin and the password is at /var/lib/jenkins/secrets/initialAdminPassword

CLI

Downloading the client

ssh authentication (optional)

  • Create id_rsa and id_rsa.pub.
$ cd ~/.ssh/
$ ssh-keygen -t rsa -b 4096

CLI commands

Now you can control jenkins by the following command.

$ java -jar jenkins-cli.jar -s http://localhost:8082/ -auth admin:PASSWORD [command]
  • Add a job [command]
create-job JOB_NAME < config.xml

The format of config.xml file please checkout /var/lib/jenkins/jobs/JOB_NAME/config.xml.

  • Delete a job [command]
delete-job JOB_NAME 

References