jenkins - 如何让 Jenkins 从远程根目录执行管道步骤?
问题描述
我在 Jenkins 中创建了一个简单的管道。我的代理的远程根目录设置为我的项目根路径。但是当我测试时,我在构建期间所处的位置(例如,通过定义类似的步骤sh 'pwd'
),我看到目录,我的步骤是从$WORKSPACE
目录(/path_to_remote_root_directory_of_the_agent/workspace/jenkins_project_title
)执行的。这意味着,我既不能开始我的单元测试sh 'vendor/bin/phpunit ./test/Unit'
,也不能开始我通常从项目根文件夹运行的其他任务。
我很确定,我只是错误地配置了一些东西,在正常情况下,像这样的脚本
pipeline {
agent {
label 'devvm-slave-01'
}
stages {
stage('Prepare') {
steps {
sh 'composer install'
...
}
}
...
stage('Checkstyle') {
steps {
sh 'vendor/bin/phpcs --report=checkstyle --report-file=`pwd`/build/logs/checkstyle.xml --standard=PSR2 --extensions=php --ignore=autoload.php --ignore=vendor/ . || exit 0'
checkstyle pattern: 'build/logs/checkstyle.xml'
}
}
}
}
按预期工作,没有任何粗略的路径解决方法。
我做错了什么以及如何让它正常工作?
解决方案
推荐阅读
- php - 在 codeigniter 中使用 $this 时不在对象上下文中
- java - 比较 url 字符串的路径。忽略域名
- javascript - ChartJS:设置图表加载时显示哪些数据并保存(记住)它
- jquery - 在发出请求之前覆盖 ajax 请求以更改 url
- javascript - 如何创建具有函数返回结果的数组?
- vba - 从展开/折叠数据透视表中提取“隐藏”数据 - Excel
- javascript - Lodash:提取属性,拆分数组,获取唯一值
- spring-boot - 如何在 Jhipster-gateway 上为微服务添加不同的速率限制
- java - 如何在后台 2 分钟后调用方法
- node.js - 如何使用nodejs将多个图像转换为单个pdf