“你好,希望你一切都好。我是Jenkins的新手,在实践中遇到了错误。我拿了一个样本项目。错误和Jenkins文件内容张贴在下面,请看看它。有什么问题尽管问。请提出解决方案。
感谢您的支持和帮助。`
Error as below
Started by user admin
Obtained Jenkins-decnew from git https://github.com/kdhani/myweb-p1.git
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/pipeline1
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
**Selected Git installation does not exist. Using Default
**The recommended git tool is: NONE
using credential gitid
> /usr/bin/git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/pipeline1/.git # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://github.com/kdhani/myweb-p1.git # timeout=10
Fetching upstream changes from https://github.com/kdhani/myweb-p1.git
> /usr/bin/git --version # timeout=10
> git --version # 'git version 2.40.1'
using GIT_ASKPASS to set credentials
> /usr/bin/git fetch --tags --force --progress -- https://github.com/kdhani/myweb-p1.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision c8f4db412eaf023b2ae78c1a9e168db17ea6ac73 (refs/remotes/origin/master)
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f c8f4db412eaf023b2ae78c1a9e168db17ea6ac73 # timeout=10
Commit message: "Update Jenkins-decnew"
> /usr/bin/git rev-list --no-walk c8f4db412eaf023b2ae78c1a9e168db17ea6ac73 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Git Checkout)
[Pipeline] git
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential gitid
> /usr/bin/git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/pipeline1/.git # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://github.com/kdhani/myweb-p1.git # timeout=10
Fetching upstream changes from https://github.com/kdhani/myweb-p1.git
> /usr/bin/git --version # timeout=10
> git --version # 'git version 2.40.1'
using GIT_ASKPASS to set credentials
> /usr/bin/git fetch --tags --force --progress -- https://github.com/kdhani/myweb-p1.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision c8f4db412eaf023b2ae78c1a9e168db17ea6ac73 (refs/remotes/origin/master)
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f c8f4db412eaf023b2ae78c1a9e168db17ea6ac73 # timeout=10
> /usr/bin/git branch -a -v --no-abbrev # timeout=10
> /usr/bin/git branch -D master # timeout=10
> /usr/bin/git checkout -b master c8f4db412eaf023b2ae78c1a9e168db17ea6ac73 # timeout=10
Commit message: "Update Jenkins-decnew"
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Maven Build)
[Pipeline] sh
**+ mvn clean package
**/var/lib/jenkins/workspace/pipeline1@tmp/durable-7e042d4d/script.sh: line 1: **mvn: command not found**
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (deploy-dev)
Stage "deploy-dev" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
REST API
Jenkins 2.401.1
jenkins file content from here :)
pipeline{
agent any
environment{
PATH = "/opt/maven3/bin:$PATH"
}
stages{
stage("Git Checkout"){
steps{
git credentialsId: 'gitid', url: 'https://github.com/kdhani/myweb-p1.git'
}
}
stage("Maven Build"){
steps{
sh "mvn clean package"
sh "mv target/*.war target/myweb.war"
}
}
stage("deploy-dev"){
steps{
sshagent(['tomcat-new']) {
sh """
scp -o StrictHostKeyChecking=no target/myweb.war ec2-user@172.31.33.108:/home/ec2-user/apache-tomcat-9.0.63/webapps/
ssh ec2-user@172.31.33.108 /home/ec2-user/apache-tomcat-9.0.63/bin/shutdown.sh
ssh ec2-user@172.31.33.108 /home/ec2-user/apache-tomcat-9.0.63/bin/startup.sh
"""
}
}
}
}
}
1条答案
按热度按时间yqlxgs2m1#
首先,在代理路径上找到
git
,否则Jenkins将无法克隆/恢复(检出)您的存储库。其次,error只适用于Maven:
如果你有Pipeline Maven集成,请检查你的Jenkins“全局工具配置”设置页面:
确保您声明了一个Maven,其路径对于运行它的代理有效。
查看“Configuring Java and Maven in Jenkins”以获取插图。
您还可以将maven参数添加到作业中: