- Download WAR package from official website
- Configure the java environment and start: java -jar jenkins.war
- Log in to the home page and follow the prompts to find the password to log in and set the username.
- The next step is to download the plug-in, so don't download it now. Change the jenkins mirror address
#关闭jenkins进程,jenkins目录 war 启动 目录:/root/.jenkins/updates/default.json
sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.cloud.tencent.com\/jenkins/g' $JENKINS_HOME/updates/default.json
# 如果上边的命令updates.jenkins-ci.org 找不到, 换成 updates.jenkins.io
然后启动重新进入页面,下载插件,速度起飞
-
To configure various environments, home page Manage Jenkins => Global Tool Configuration What configuration needs to be run, there are a lot of searches on this Internet
-
The purpose I use here is to achieve local packaging and push to a remote server for release and operation. Install remote publishing plugin
-
Configure remote server connection information Manage Jenkins = "System Configuration, two ways (password or key)
Account password connection
Key connection
Key generation method, generated on the remote target server
Enter the command:, ssh-keygen
follow the prompts and keep Enter key to the end, press until as shown in the figure
1: Private and public keys will be generated in the .ssh directory
2: Copy the public key and rename the authorized_keys command:cp id_rsa.pub authorized_keys
3: Copy and fill in the content of the private key into the Key text box in the figure above, and test success!
- Create a new task or first create an attempt (right arrow + sign) and then create an item, which is equivalent to grouping. The default creation is in ALL.
Create a task, build a Maven project
Configure the GIT connection address and user name information.
The following figure shows the key steps of remote push, pay attention to see in detail
name: It is the custom name of ssh configured in the previous steps, the drop-down box can be seen
Source files: Source files, this path, for example: For example, the location of my jar in the jenkins workspace is:, .jenkins/workspace/test-dt-service-member/dt-member/dt-member-service/target/dt-member-service-1.0.jar
here this address is filled in:dt-member/dt-member-service/target/*.jar
Remove prefix: When uploading to the target server, you need to remove the path before the jar package. The source file above says dt-member/dt-member-service/target/*.jar
that the prefix is removed heredt-member/dt-member-service/target
Remote directory: upload to the directory of the target server, the previous ssh configuration information is /data, if you write a test here, then the file will be uploaded to the target server under /data/test
Exec command: Fill in the execution step command
The above information is configured, directly build and test
Problems that may arise:
1: Transfers 0 file, check the several issues about file paths mentioned above
2: During the execution of the script, the jenkins process will not be interrupted, keep logging in the log, turn on the advanced settings of the above picture, and check the options below
3: Jenkins during the build process, if the script spawned other processes, Jenkins finished will kill all processes in the execution of the script For example, I run a. sh start.sh
, This script has a line java - jar ***.jar
of command to start the project this time you will find Jenkins. It has been executed but the project did not start successfully. Just add nohup to the startup script.nohup sh start.sh
Jenkins executes the script without exiting, refer to this big guy