Tag Archives: jenkins

[Solved] jenkins Build python Program Error: ModuleNotFoundError: No module named ‘htmltestreport’

Background:

The project is built based on virtual environment, and the third-party packages are actually installed in:

E:\PyProject\py_basic\Lib\site-packages is not the same directory as Python installation directory

Question:

Both pycham and CMD can operate normally, but Jenkins build error:

C:\Users\86158\.jenkins\workspace\ihrm_code>python run_suite.py 
Traceback (most recent call last):
  File "run_suite.py", line 3, in <module>
    from htmltestreport import HTMLTestReport
ModuleNotFoundError: No module named 'htmltestreport'

Solution:

Add environment variables to Jenkins. This problem is usually caused by the configuration of environment variables

[Solved] Jenkins Machine install kubelet Error: authentication failed

1. Look at jenkinsfile

2. Check the error message and the authentication fails

I can see that the authentication failed, but my Jenkins machine was successful in executing the kubectl command
[root@devops ~]# kubectl get pod 
NAME                                      READY   STATUS    RESTARTS   AGE
nexus3-7b7598945f-njgpn                   1/1     Running   1          6d6h

3. Modified

My authorization file is validated by environment variables, which are placed in /etc/profile, and /etc/profile is only loaded when the user logs in, Jenkins uses Non-login when running the command

jenkins Build Error: “‘: Failed to establish a new connection: [Errno -2] Name or service not known'”

Problem phenomenon

An error is reported when an interface request is initiated in Jenkins container:

Analysis

Report that the host cannot be obtained. Ping the host domain name in the Jenkins container (if Ping is not installed, install the Ping tool first). If the Ping fails, it indicates that the network connection configuration is wrong

Solution:

A new line of configuration is added to/etc/hosts in Jenkins container. The format is: host IP address domain name

If necessary, check testerhome Com initiates a request, first use the ping command to determine the IP, and then edit it into the hosts file

Precautions

After restarting the container each time, the hosts file will be initialized, resulting in the invalidation of the previously added configuration. You can continue to add
after restarting

docker exec -it -u root 647bf755ba2e /bin/bash -c "echo -e $loccalhost_ip $domain1 $domain2 >> /etc/hosts"

[Solved] Jenkins deploy task error: Host key verification failed

Environment configuration: Jenkins + gitlab deployment

Jenkins reported the following error: host key verification failed; could not read from remote repository

Xshell logs in to the background to view the problems during deployment

The background directly uses the GIT command gitllab to check in locally

Then go to the page to deploy the task, and you can succeed

After Jenkins installation, the plug-in installation failed. Error suncertpathbuilderexception

Jenkins plug-in cannot be downloaded

SSL problem of Java
manually install a skip certificate check plug-in through the address https://updates.jenkins.io/download/plugins/skip-certificate-check/1.0/skip-certificate-check.hpi Download

Then manually install the plug-in through Jenkins and restart. Then you can update it.

Jenkins auto deploy web project daily use error 1

The company’s project is automatically deployed with Jenkins + Maven + Tomcat. If it is used more times, an error message will be reported after the build is successful:

java.nio.file.FileSystemException: /var/lib/jenkins/workspace/gydl_sc/target/gydl.war -> /var/lib/jenkins/jobs/gydl_sc/modules/com.thinkgem.jeesite$gydl/builds/26/archive/com.thinkgem.jeesite/gydl/1.2.7/gydl-1.2.7.war: No space on the device
In this case, the server directory /var/lib/jenkins/jobs/gydl_sc/modules/com.thinkgem.jesite$gydl/builds/ is not enough space, just delete the files stored during previous deployments

An error is reported when the docker command is executed in Jenkins

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

When Jenkins is configured to automatically build dockerfiles from gitlab and upload them to harbor, the above problems are encountered. When Jenkins executes the docker command, the above errors will be reported. After consulting relevant data, it is found that the solutions are as follows:
I Modify docker service configuration
systemctl stop docker
sudo gpasswd - a Jenkins docker # add Jenkins users to the docker group
VIM/usr/lib/SYSTEMd/system/docker. Service

#ExecStart=/usr/bin/dockerd-current \
#          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
#          --default-runtime=docker-runc \
#          --exec-opt native.cgroupdriver=systemd \
#          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
#          $OPTIONS \
#          $DOCKER_STORAGE_OPTIONS \
#          $DOCKER_NETWORK_OPTIONS \
#          $ADD_REGISTRY \
#          $BLOCK_REGISTRY \
#          $INSECURE_REGISTRY\
#         $REGISTRIES
ExecStart=/usr/bin/docker daemon -H unix:// -H tcp://192.168.1.1:2375
#Replace the above commented configuration file with the newly added file below.

systemctl daemon reload
systemctl restart docker
2. Restart the Jenkins service, build the current project, and check whether the relevant docker commands can be executed
systemctl restart Jenkins
If you encounter the problem that the filtering Jenkins process shows that the current service has been closed, but Jenkins still cannot be started, you can execute the java - jar Jenkins. War command to see the detailed error messages. What’s more wonderful is that I have closed the Jenkins process, the filtering service and port have been closed, but the address occupied error will still be reported when starting the Jenkins service, At this point, re execute the systemctl stop Jenkins command, and then start the Jenkins service to see if it can be solved

 

Two pits with Jenkins operation error

Jenkins was configured in the tutorial yesterday, but there are always errors. Summarize the two problems encountered

1. It can run normally in pycharm, but the error “no module named ‘xxx” is always reported under Jenkins. It is also reported by using the command line alone. The reason for checking online is

In pycharm, all folder paths of the current project will be used as the package search path at runtime, while only the current path will be searched by default on the command line, and the package will not be found

To solve this problem, I used a stupid method to add the paths of the current folder to the search path through sys. Path. Append()


After adding the path, run the code from the command line successfully

2. The second problem is that after running successfully through the command line, Jenkins still reports an error. It reports that the module in the python directory cannot be found. After checking, it is said on the Internet that Jenkins may have permission to read some folders

The solution is as follows

Run – > services.msc

Find Jenkins

 

Right click – properties – login – this account

Select an account with permission (you must have a login password, otherwise an error will occur when restarting the service)

After application, restart the service

 

Rebuild in Jenkins and run successfully

 


[Solved] Jenkins deployed the war package to tomcat7 and reported an error

[JENKINS] Archiving/opt/.jenkins/jobs/qxpt -jx-deploy/workspace/pom.xml to com.ichangyan.tsp/qxpt -u jx/2.0/qxpt

[JENKINS] Archiving /opt/.jenkins/jobs/qxpt_jx-deploy/workspace/target/qxpt_jx.war to com.ichangyan.tsp/qxpt_jx/2.0/qxpt_jx-2.0.war
channel stopped
Deploying /opt/.jenkins/jobs/qxpt_jx-deploy/workspace/target/qxpt_jx.war to container Tomcat 7.x Remote
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [/opt/.jenkins/jobs/qxpt_jx-deploy/workspace/target/qxpt_jx.war]
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:189)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:990)
	at hudson.FilePath.act(FilePath.java:968)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1037)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
	at hudson.model.Run.execute(Run.java:1763)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:410)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:555)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174)
	... 16 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://172.16.xx.xx:8080//manager/text/list
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:544)
	... 19 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:555)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:990)
	at hudson.FilePath.act(FilePath.java:968)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1037)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
	at hudson.model.Run.execute(Run.java:1763)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:410)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://172.16.XX.XX:8080//manager/text/list
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:544)
	... 19 more
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE

 

Analysis:

This problem is caused by the definition of user permissions for tomcat 7, as follows

manager-gui — Access to the HTML interface.

manager-status — Access to the “Server Status” page only.

manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the “Server Status” page.

manager-jmx — Access to JMX proxy interface and to the “Server Status” page.

You must define the permissions of the deployment user as “manager-script” for the deployment to succeed.

Solution:

1. You need to modify the tomcat-users.xml file in the conf folder of tomcat

<role rolename=”manager-gui”/>

<role rolename=”manager-script”/>

<user username=”admin” password=”admin” roles=”manager-gui,manager-script”/>

2, restart the service can be (under linux)

./shutdown.sh

./startup.sh

 

[Solved]Jenkins Error: ERROR_ Failed to parse POMs

I. In the process of writing with jenkins, the following problems suddenly appeared

Parsing POMs Established TCP socket on 59407 [java] $ java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12-alpha-1.jar:/usr/local/apache-maven-3.5.4/boot/plexus-classworlds-2.5.2.jar:/usr/local/apache-maven-3.5.4/conf/logging jenkins.maven3.agent.Maven35Main /usr/local/apache-maven-3.5.4 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.23.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12-alpha-1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 59407 ERROR: Failed to parse POMs java.io.IOException: Cannot run program “java” (in directory “/var/lib/jenkins/workspace/java”): error=2, Not having that file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at hudson.Proc$LocalProc.<init>(Proc.java:249) at hudson.Proc$LocalProc.<init>(Proc.java:218) at hudson.Launcher$LocalLauncher.launch(Launcher.java:929) at hudson.Launcher$ProcStarter.start(Launcher.java:449) at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:278) at hudson.maven.ProcessCache.get(ProcessCache.java:236) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:804) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1815) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Caused by: java.io.IOException: error=2, Not having that file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) … 12 more Email was triggered for: Always Sending email for trigger: Always Sending email to: [email protected] Finished: FAILURE

Solution:

The above error message is not specified JDK path, the solution: is in the Jenkins system management → global tools configuration → find the JDK configuration items in JAVA_HOME set your jdk directory path, save restart Jenkins on the line!