jenkins 使用所遇报错

 > git --version # timeout=10
 > git --version # 'git version 2.25.1'
using GIT_ASKPASS to set credentials 
 > git fetch --tags --force --progress -- https://github.com/finally-test-dog/api_pytest.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url https://github.com/finally-test-dog/api_pytest.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse origin/master^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
[apipytest] $ /var/lib/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /var/lib/jenkins/workspace/apipytest/allure-report
allure-results does not exist
Report successfully generated to /var/lib/jenkins/workspace/apipytest/allure-report
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
Finished: FAILURE

跟因:配置中的源码管理的 代码分支不对

办法:根据实际代码仓库分支 命名

 

二、

1     at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:519)
2     at hudson.model.Run.execute(Run.java:1899)
3     at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
4     at hudson.model.ResourceController.execute(ResourceController.java:107)
5     at hudson.model.Executor.run(Executor.java:449)
6 ERROR: Error cloning remote repo 'origin'
7 [apipytest] $ /var/lib/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /var/lib/jenkins/workspace/apipytest/allure-report
8 allure-results does not exist

问题:

1.git拉取代码权限不对

2.jenkins 的git路径配置不对

办法:

1.查看代码项目的公开的,问题1排除

2.

(1)如jenkins是本地服务器 系统配置-全局工具配置 下把配置git的路径修改成 本地路径

(2)Jenkins在 云服务器上,执行

sudo apt install git 

git version

我是第二种情况

三、

1 [apipytest] $ /bin/bash /tmp/jenkins1764652657208851901.sh
2 /tmp/jenkins1764652657208851901.sh: line 3: pip: command not found
3 /tmp/jenkins1764652657208851901.sh: line 4: pytest: command not found
4 Build step 'Execute shell' marked build as failure
5 [apipytest] $ /var/lib/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /var/lib/jenkins/workspace/apipytest/allure-report
6 allure-results does not exist
7 Report successfully generated to /var/lib/jenkins/workspace/apipytest/allure-report

问题:执行shell脚本失败,

原因1:pip: command not found,

原因2:pytest: command not found

办法:

解决原因1:jenkins所在的linux服务器未安装pip3,执行 

sudo apt install python3-pip

解决原因2:在1基础上,执行

sudo pip3 install pytest

然后构建还是会报同样错误,需在shell脚本中使用绝对路径,服务器执行

which pytest 

获取pytest路径后,把shell脚本中的 pytest 替换

 

 

posted @ 2022-10-03 17:53  版本还你,不测了  阅读(827)  评论(0编辑  收藏  举报