这段Jenkins pipeline有什么问题:pipeline{ agent{ node { label "MCU_Win10_DLDVNFF3X" customWorkspace "smart_MCU_WORKSPACE" } }//end of agent options { timestamps() } environment{ Project_MCU_GIT_URL = "https://gitgerrit.cn.asux.aptiv.com/a/10056024_smart_ADCU_MY25_MCU_APP" Credentials_path = "c:\\Users\\zjqwkn\\" GIT_SSL_NO_VERIFY = "false" GIT_HTTP_SSL_VERIFY = "true" } stages{ stage("Download source project From Git"){ steps{ script{ echo "Download source project from gerrit:" bat'''@echo on git config --global http.sslVerify true echo "Display the current directory:" git config -l dir /b if exist 10056024_smart_ADCU_MY25_MCU_APP\\.git\\ ( echo "already have git, clean it and update it" cd 10056024_smart_ADCU_MY25_MCU_APP git stash && git clean -f -d && git stash clear git pull origin master ) else ( echo "git clone a new 10056024_smart_ADCU_MY25_MCU_APP" git clone "%Project_MCU_GIT_URL%" ) echo "update ok!!!" ''' sleep 1 } } }//end of stage stage("Build source project"){ steps{ script{ echo "Build source project:" bat''' echo "Display the current directory:" CD ''' } } }//end of stage }//end of stages }//end of pipeline
时间: 2024-02-10 08:18:14 浏览: 108
这段Jenkins pipeline有以下问题:
1. 该Pipeline缺少构建步骤,应该在“Build source project”阶段添加构建步骤。
2. 在Pipeline的环境变量中,Credentials_path应该是一个完整的路径,而不是仅包含用户名的路径。
3. 在Pipeline的环境变量中,GIT_SSL_NO_VERIFY应该设置为"true"而不是"false",以避免因SSL验证失败而中断Pipeline。
4. 在Pipeline的环境变量中,GIT_HTTP_SSL_VERIFY应该设置为"false"而不是"true",以避免因SSL验证失败而中断Pipeline。
5. 在Pipeline的“Download source project From Git”阶段中,应该在bat脚本中使用%Credentials_path%而不是硬编码的用户名路径。
6. 在Pipeline的“Build source project”阶段中,应该在bat脚本中使用正确的命令来构建项目,而不是仅输出当前目录。
相关问题
pipeline { agent any options { timeout(time: 2, unit: 'DAYS') } stages { stage('git pull') { steps { echo 'git pull' dir('/var/lib/jenkins/workspace/CI_Code_Pull') { git credentialsId: 'pw_lh', url: 'http://172.16.2.83/testtools/PaxTestByPytest.git', branch: 'auto_ci' } } } stage('Build') { steps { timeout(time: 48, unit: 'HOURS') { build job: 'CI_Version_Test_Child', parameters: [ string(name: 'serialNo', value: '172.16.120.187:6714'), string(name: 'product_name', value: 'A80'), string(name: 'os_path', value: 'ftp://172.16.2.161/pub/os/A80S/PayDroid_10.0_Cedar_V17.2.12T0_20230713_Release.paydroid'), string(name: 'runtime', value: '430'), string(name: 'app_runtime', value: '360'), string(name: 'monkeyapp_runtime', value: '180'), string(name: 'packageList', value: 'com.android.camera2,com.android.documentsui') ], wait: false build job: 'CI_Version_Test_Child', parameters: [ string(name: 'serialNo', value: '172.16.120.187:6713'), string(name: 'product_name', value: 'A80'), string(name: 'os_path', value: ''), string(name: 'runtime', value: '430'), string(name: 'app_runtime', value: '360'), string(name: 'monkeyapp_runtime', value: '180'), string(name: 'packageList', value: 'com.android.camera2,com.android.documentsui') ], wait: false } } } } } 两个CI_Version_Test_Child是串行还是并行构造
根据你提供的Jenkins Pipeline代码,使用了两个`build`步骤分别调用了`CI_Version_Test_Child`作业,并且设置了`wait: false`参数。这表示两个`build`步骤会并行执行,而不是串行执行。
设置`wait: false`参数可以使得每个`build`步骤在启动作业后立即继续执行下一个步骤,而不需要等待作业完成。这样可以提高流水线的执行效率,但也可能导致并行执行的作业之间存在依赖关系时出现问题。
如果你希望两个`CI_Version_Test_Child`作业串行执行,可以将其中一个`build`步骤的`wait`参数设置为`true`,这样第一个作业完成后才会继续执行下一个步骤。例如:
```
build job: 'CI_Version_Test_Child', parameters: [...], wait: true
build job: 'CI_Version_Test_Child', parameters: [...], wait: false
```
这样第一个作业完成后,才会继续执行第二个作业。
[2023-05-31 11:07:02] Started by user coding [2023-05-31 11:07:02] Running in Durability level: MAX_SURVIVABILITY [2023-05-31 11:07:04] [Pipeline] Start of Pipeline [2023-05-31 11:07:06] [Pipeline] getContext [2023-05-31 11:07:07] [Pipeline] node [2023-05-31 11:07:07] Running on Jenkins in /root/codingci/tools/jenkins_home/workspace/2553946-cci-31810232-464995 [2023-05-31 11:07:07] [Pipeline] { [2023-05-31 11:07:08] [Pipeline] withEnv [2023-05-31 11:07:08] [Pipeline] { [2023-05-31 11:07:08] [Pipeline] withDockerRegistry [2023-05-31 11:07:08] [Pipeline] { [2023-05-31 11:07:08] [Pipeline] isUnix [2023-05-31 11:07:08] [Pipeline] sh [2023-05-31 11:07:08] + docker inspect -f . public/docker/nodejs:18-2022 [2023-05-31 11:07:08] /root/codingci/tools/jenkins_home/workspace/2553946-cci-31810232-464995@tmp/durable-221f7a67/script.sh: 1: docker: not found [2023-05-31 11:07:08] [Pipeline] isUnix [2023-05-31 11:07:08] [Pipeline] sh [2023-05-31 11:07:09] + docker inspect -f . coding-public-docker.pkg.coding.net/public/docker/nodejs:18-2022 [2023-05-31 11:07:09] /root/codingci/tools/jenkins_home/workspace/2553946-cci-31810232-464995@tmp/durable-4892b310/script.sh: 1: docker: not found [2023-05-31 11:07:09] [Pipeline] isUnix [2023-05-31 11:07:09] [Pipeline] sh [2023-05-31 11:07:09] + docker pull coding-public-docker.pkg.coding.net/public/docker/nodejs:18-2022 [2023-05-31 11:07:09] /root/codingci/tools/jenkins_home/workspace/2553946-cci-31810232-464995@tmp/durable-0770ad1b/script.sh: 1: docker: not found [2023-05-31 11:07:09] [Pipeline] } [2023-05-31 11:07:09] [Pipeline] // withDockerRegistry [2023-05-31 11:07:09] [Pipeline] } [2023-05-31 11:07:09] [Pipeline] // withEnv [2023-05-31 11:07:09] [Pipeline] } [2023-05-31 11:07:09] [Pipeline] // node [2023-05-31 11:07:09] [Pipeline] End of Pipeline [2023-05-31 11:07:09] ERROR: script returned exit code 127 [2023-05-31 11:07:09] Finished: FAILURE
根据你提供的日志信息,可以看到其中出现了以下错误信息:
```
docker: not found
```
这个错误一般是因为你的机器上没有安装 Docker,或者 Jenkins 没有正确配置 Docker 环境。请检查一下你的机器上是否安装了 Docker,如果没有,请先安装 Docker,然后再重新配置 Jenkins 的 Docker 环境。如果你已经安装了 Docker,那么可能是 Jenkins 的 Docker 环境配置有误,请检查一下 Jenkins 的 Docker 环境配置是否正确。
阅读全文