- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
作为管道构建作业的一部分,我需要检查工作区中是否存在某个 .exe 文件。我尝试使用 Jenkinsfile 中的以下 Groovy 脚本来执行相同的操作。但我认为默认情况下 File 类会尝试在 jenkins master 上查找工作区目录并失败。
@com.cloudbees.groovy.cps.NonCPS
def checkJacoco(isJacocoEnabled) {
new File(pwd()).eachFileRecurse(FILES) { it ->
if (it.name == 'jacoco.exec' || it.name == 'Jacoco.exec')
isJacocoEnabled = true
}
}
如何从 Jenkinsfile 内部使用 Groovy 访问从属设备上的文件系统?
我也尝试了下面的代码。但我收到 No such property: build for class: groovy.lang.Binding
错误。我还尝试改用管理器对象。但遇到同样的错误。
@com.cloudbees.groovy.cps.NonCPS
def checkJacoco(isJacocoEnabled) {
channel = build.workspace.channel
rootDirRemote = new FilePath(channel, pwd())
println "rootDirRemote::$rootDirRemote"
rootDirRemote.eachFileRecurse(FILES) { it ->
if (it.name == 'jacoco.exec' || it.name == 'Jacoco.exec') {
println "Jacoco Exists:: ${it.path}"
isJacocoEnabled = true
}
}
最佳答案
遇到同样的问题,找到了解决方案:
import hudson.FilePath;
import jenkins.model.Jenkins;
node("aSlave") {
writeFile file: 'a.txt', text: 'Hello World!';
listFiles(createFilePath(pwd()));
}
def createFilePath(path) {
if (env['NODE_NAME'] == null) {
error "envvar NODE_NAME is not set, probably not inside an node {} or running an older version of Jenkins!";
} else if (env['NODE_NAME'].equals("master")) {
return new FilePath(path);
} else {
return new FilePath(Jenkins.getInstance().getComputer(env['NODE_NAME']).getChannel(), path);
}
}
@NonCPS
def listFiles(rootPath) {
print "Files in ${rootPath}:";
for (subPath in rootPath.list()) {
echo " ${subPath.getName()}";
}
}
这里重要的是 createFilePath()
没有用 @NonCPS
注释,因为它需要访问 env
变量。使用 @NonCPS 会删除对“管道优点”的访问,但另一方面,它并不要求所有局部变量都是可序列化的。然后,您应该能够在 listFiles()
方法中搜索文件。
关于jenkins - 使用 FilePath 访问 Jenkins 管道中从属设备上的工作区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41250567/
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 4年前关闭。 Improve this questi
我已经完成了注册页面,并且运行顺利。 现在我需要弄清楚登录部分。我想要它,所以一旦用户登录,它就会将他们带到私有(private)页面,只有登录的用户才能看到。 它不需要针对每个用户进行个性化设置,只
出于个人好奇心,我目前正在学习区 block 链的工作原理。我正在学习这门类(class),现在我已经使用网络套接字设置了点对点连接。区 block 链应用程序的多个实例现在可以使用这些套接字运行并相
我读过: The blockchain database isn’t stored in any single location, meaning the records it keeps are t
Closed. This question needs to be more focused。它当前不接受答案。 想要改善这个问题吗?更新问题,使它仅关注editing this post的一个问题。
如果我在区块链中进行交易,是否只有在将交易添加到区块链后才会进行比特币转账?如果是这样,挖掘区块可能需要时间,并且无法进行紧急付款。那么这不是区块链的劣势吗? 最佳答案 如果您不重视能够在没有第三方(
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题
根据我的理解,我读到的关于区 block 链的所有内容都表明,即使在私有(private)区 block 链上,每个参与者都可以查看所有交易。我看到它提到区 block 链的一个用例可能是共享医疗数据
服务器正在发送消息时,如何阻止连接到服务器的一个IP地址。我的发送消息选项程序如下所示。 private void buttonSendMsg_Click(对象发送者,EventArgs e) {
iam正在hadoop apache 2.7.1上工作 和iam添加大小不超过100 Kb的文件 所以如果我将块大小配置为1 mb或默认值是 128兆字节 不会影响我的文件,因为它们只会保存在一个块中
我有一个docker-compose文件here。我可以连接到7051并注册我的chaincode客户端,但是当我尝试连接到localhost:7050时,我得到一个错误,该错误在使用curl测试时如
从数据类型来看,区 block 链是单链表吗?因为每个 block 都使用哈希引用前一个 block 。 或者它是某种树? 最佳答案 区 block 链表示为单链表的方式。每个 block 都有前一个
我无法理解给定代码片段的 hashcode() 部分。 我尝试过搜索它,但我无法弄清楚。 this.hash = Arrays.hashCode(new Integer[]{data.has
已关闭。这个问题是 not about programming or software development 。目前不接受答案。 这个问题似乎不是关于 a specific programming
我正在通过一些在线示例学习区 block 链。我有这个高级代码,我用以前的哈希创建一个新 block ,然后向它添加一个事务,然后生成 block 的困难哈希(有 8 个前导零) Block blo
我们有一个包含一些数字商品的网站。从那里购买的用户需要用 BTC 购买一些信用。在他购买信用卡后,脚本必须将他用 BTC 购买的货币 (USD) 数量加载到他的账户中。 所以这里我们有 HTML 表单
我目前正在使用 enumerateObjectsUsingBlock block 在 subview 下进行枚举,我怎样才能确定 block 的完成? 下面是区 block 内容 [self.view
我通常将显示 block 放在链接上,以使按钮的所有 div 都处于事件状态,而不仅仅是文本。但在这种情况下,我需要在 ul li 中使用 display:inline-block 我认为这会禁用其他
我正在尝试创建付款账单并通过电报机器人发送给我的客户:我正在使用区 block 链 API V2-https://blockchain.info/api/api 接收。我的代码是: xpub='***
有个面试题:区 block 链和不可变链表有什么区别? 我回答他们是相同的技术,然后没有通过测试。请纠正我的错误。 最佳答案 链表中的每一项通常通过指针或内存地址指向链表中的下一项。 区 block
我是一名优秀的程序员,十分优秀!