Example: In the Linux environment, the installed jenkins, integrated svn, the project is the maven project Jenkins configuration
On the Jenkins homepage, click on Manage Jenkins, then click Manage Plugins to manage the necessary plugins, svn, maven, ssh, etc.
Then Jenkins home page, click Manage Jenkins, then click Global Tool Configuration tool configuration, configure JDK, Maven, etc.
Jenkins use
The first step: create a new task on the home page, then fill in the task name, select the free style project
The second step, the project name, can be modified
Step 3: Add the svn address and set it, username and password
Step 4: When building, there are three situations
Case 1, using maven for project construction, using plugin release
The fourth step: When constructing, there are two situations. It is recommended to use a third party.
Case 1, using maven for project construction, using plugin release
Post-build operation, use the plug-in to publish the project, publish the project, the plug-in required for the project release is (Deploy to container Plugin), publish to tomcat, need to use the tomcat username and password, tomcat users can themselves in tomcat Configured in conf/tomcat-users.xml file
Tomcat-users.xml configuration
Case 2, use the shell command to build the project, and then directly use the command to publish. When executing tomcat startup, you need to add the command export BUILD_ID=dontKillMe
Jenkins build output
Case 3, use the shell command to build the project, and then directly use the command to publish. When executing tomcat startup, you need to add the command export BUILD_ID=dontKillMe
Script source code:
Export BUILD_ID=dontKillMe
Rm -rf /alidata/ejoined/server/apache-tomcat-8365/webapps/ROOT
Cp -R /var/lib/jenkins/workspace/adsl-taobao-admin/target/ROOT.war /alidata/ejoined/server/apache-tomcat-8365/webapps/
Tomcatpath=“/alidata/ejoined/server/apache-tomcat-8365â€
Pid=$(ps -ef | grep java | grep ${tomcatpath} | awk '{print $2}')
Kill -9 $pid
Rm -rf ${tomcatpath}/work/Catalina/localhost/*
Sleep 1
${tomcatpath}/bin/startup.sh
Completed above;
But there will be some anomalies; as follows:
As shown in the figure above: the compilation is successful, but no matter how the script is executed, there is no permission (Permission denied).
I have finally gotten the time for such a problem. How to solve that?
Start below, from the analysis of the problem, it can be seen that the current user name used by the current Jenkins user on the host Linux server is incorrect.
That's the problem,
Let's start by explaining the solution steps:
1. First check where you want to use the script to run the script, the target file or directory pointed to by the script in case three in this article is (/alidata/ejoined/server/apache-tomcat-8365), all the things under this file, Look at the executable user on the directory pointed to, as shown below:
As you can see from the figure, the executable user is root.
The target file or directory pointed to by the script must have executable permissions;
Modify permission command: chmod -R 755 target directory name
2. Know the directory pointed to by the script or the user pointed to by the file, then the next step is solved.
How to modify the Linux account running the jenkins process?
1, find the configuration file of jenkins, usually /etc/sysconfig/jenkins
2. Modify the following parameters to the corresponding user, such as JENKINS_USER=“rootâ€
## Type: string
## Default: "jenkins"
## ServiceRestart: jenkins
#
# Unix user account that runs the Jenkins daemon
# Be careful when you change this, as you need to update
# permissions of $JENKINS_HOME and /var/log/jenkins.
#
JENKINS_USER=“jenkinsâ€
3, restart jenkins: service jenkins restart
Open the browser to enter the address, start again from the compilation of the first project, and then you will find success.
Suizhou simi intelligent technology development co., LTD , https://www.msmvape.com