1. Install the Jenkins
Environment: CentOS 7.0
Installation method:
$ yum install yum-fastestmirror -y Install the plugin that automatically selects the fastest source
# Add Jenkins source:
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
$ yum install jenkins # installation JenkinsCopy the code
Startup mode:
$ sudo service jenkins start
Access mode:
Enter http://your server IP address :8080/
Change configuration (such as port) :
$ vim /etc/sysconfig/jenkins
$ sudo service jenkins restartCopy the code
2. Jenkins basic configuration
Unlock
After the above configuration, you can access your Jenkins by typing http://your server IP :8080/ in your browser.
According to clew we perform the cat/var/lib/Jenkins/secrets/initialAdminPassword get Administrator password, click the Continue after input, as follows:
Select Install Suggested Plugins and wait until the installation is complete. If any installation fails, skip it and install it manually as required.
Set the initial account and password
Enter the interface after setting:
3. Making configuration
sercret text
Note: An account with write permission on the project is required here
Go to Github –> Setting –> Personal Access Token –> Generate new Token
Save the token for yourself. If you lose it, you can’t find it again.
Making webhooks set
Go to the specified project on GitHub –> Setting –> WebHooks&Services –> Add webhook –> enter the IP address of the server where Jenkins was just deployed
4. Jenkins’ Github configuration
Installation of making the Plugin
System Management –> Plug-in Management –> Optional plug-ins
The plain-credentials, Git, Github credentials, and Github-API plugins can be installed automatically when you install the Github Plugin
Configuration is making the Plugin
System Settings — GitHub — Add GitHub Sever
As shown in the figure below
Enter https://api.github.com for THE API URL, click Add to Add the Credentials, and select Secret Text for Kind, as shown in the following figure.
After the setting is complete, click TestConnection. When the Credentials verified for user UUserName, rate Limit: XXX is displayed, the service is valid.
Create a Freestyle task
– General Set GitHub project URL, that is, your project homepage eg. https://github.com/your_name/your_repo_name
– Configure source code management
- Enter the git address of the project, eg.
https://github.com/your_name/your_repo_name.git
- Add a Github user and password
- Select the GithubWeb source library browser and fill in your project URL so that each build will generate the corresponding changes and you can link directly to Github to see the details
– Build triggers, build environments
– build
– Operation after build
Finally, click Save
5. Test the effect
Test Effect 1
Test Effect 2
6. References:
Summary of Jenkins+Github Continuous integration
This article is transferred from another’s article