This article is a detailed documentation of installing Jenkins in Ubuntu step by step. Since I found many tutorials on installing Jenkins in Linux, Not very satisfied so I decided to write a for later use (finally let me find Java without going to the official website download method ~haha) in order to write an article, cruel to my Windows server reinstalled, acceptable sorrow.

Preparation before installation

  • An Ubuntu host installation tutorial (this article uses Ubuntu Server 16.04.1 LTS)

  • Use WinSCP to remotely connect to Ubuntu. Use PuTTY to download the software

If you happen to be an Ubuntu user of Tencent Cloud, the default user name is Ubuntu

Ubuntu enables root Settings

To log in as root, you need to set the password of user root for the first activation :sudo passwd. After setting the password twice, you can switch to user root by running su root. You also need to set the value of PermitRootLogin in /etc/ssh/sshd_config to yes and restart the SSH service :sudo service SSH restart

There are some basic poses I wish someone could tell me when I first started Linux

Many, many commands are used and searched.

  • To switch users, run the su root command

  • Permission problem: If a non-root account adds sudo to the command, the super administrator will execute the command

  • Common commands are as follows: ls -a: displays all files and directories PWD: displays the current path lsb_release -a: displays the system version ifconfig: displays information such as the IP address ps: displays information about running processes learn more

  • The following commands are commonly used by vim: I: input mode (press I to open a file using vim and then move the cursor to enter ~), w: save, q: exit, wq: save and exit, q! : Exit save to learn more

  • Download software: wget XXX, curl XXX

All ready, LINK START

Install Jenkins

First time installers can look at Jenkins’ installation documentation a little bit but anyway, if you don’t have Java installed you need to install it.

Here are the easiest ways to install Java in Ubuntu that have been found so far

Java installation

Reference: https://blog.csdn.net/geekun/article/details/51325525

sudo add-apt-repository ppa:openjdk-r/ppa
I need to hit enter
sudo apt-get update
echo y|sudo apt-get install openjdk-8-jdk
Copy the code

The installation of Jenkins

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.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
echo y|sudo apt-get install jenkins
Copy the code

The operation of the Jenkins

Jenkins runs as a service, so the following two management services can be used, using port 8080 by default

Sudo service Jenkins start

Related services command: sudo service Jenkins start | stop | restart

Firewall problem

Ps: The default firewall is disabled in the host of Tencent cloud (sudo ufw status check).

Jenkins configuration

At this point, Jenkins can be accessed at http://ip:8080, and it’s time to initialize and use

  1. usecat /var/lib/jenkins/secrets/initialAdminPasswordView the initial password and log in from your browser
  2. Install the recommendation or optional plug-in (use the recommendation for the first time, you can adjust it later according to your own needs)
  3. Creating the first administrator is omitted
  4. Set Jenkins url..

Officially the Jenkins tour begins

The pit of tread

  • Shell scripts cannot access environment variables. The solution is to add #! /bin/bash-ilex, this is a solution that can be accessed on the terminal after I install NVM, but not when Jenkins builds shell scripts

    Use the -i and -l arguments to make bash the login shell and interactive shell, You can read files such as /etc/profile and ~/. Bash_profile. The e parameter means exit the current shell in case of error, and the x parameter means display every command executed

conclusion

In the process of use, there are a lot of need to record, and then gradually summarize. The idea is to eventually build your own Jenkins mirror and add a few of your own tech stack release templates to it, which would be fun to try and summarize. Recently, it was not easy to deploy the project to the server with Jenkins+Docker. In the process of looking for materials, I found it difficult to find what I wanted at once. Sure enough, I still had to make a summary by myself. Later will also use, while now summarize one or two, later will not look for articles, ha ha.

Refer to the article

  • IO /doc/book/in…
  • Ubuntu allow root remote login configuration: www.cnblogs.com/TechSnail/p…
  • Under Linux fast to install and configure jdk8:blog.csdn.net/geekun/arti…
  • Jenkins shell Command prompt “Command not found” solution: blog.csdn.net/huodoubi/ar…