小编Nel*_*llo的帖子

如何让 Jenkins lastBuild API 与多分支管道一起工作?

过去,我从 Jenkins 获取最后的构建详细信息没有任何问题,但我遇到了一个配置奇怪的企业环境,其中 API url 的结构如下:

\n\n
https://example.com/job/group-name/job/project-name/api/json\n
Run Code Online (Sandbox Code Playgroud)\n\n

我可以找到此层次结构中特定分支的最后一个构建:

\n\n
https://example.com/job/group-name/job/project-name/job/branch-name/lastBuild/api/json\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是,到目前为止,如何获得项目的最后一个版本(无论分支如何)已经违背了我的所有努力。

\n\n

我可以告诉你,明显的(以及我尝试过的所有非明显的变体)确实是行不通的。例如,这是一个彻底的失败:

\n\n
https://example.com/job/group-name/job/project-name/lastBuild/api/json\n
Run Code Online (Sandbox Code Playgroud)\n\n

并返回“此页面无法正常工作example.com已将您重定向了太多次。”

\n\n

我猜测工作 URL 中 /job/ 的多个副本是不寻常结构的症状,因此如果有人有任何想法,我会洗耳恭听!

\n

jenkins multibranch-pipeline

6
推荐指数
0
解决办法
707
查看次数

如何使用适用于Ruby的Google Drive API重命名文件?

这似乎是一个基本问题,但我现在已经进入第二天了:(

我在这里使用Google Drive Ruby Api:https://github.com/google/google-api-ruby-client但README中的基本文件示例似乎已过时.特别是,调用Drive.update_file不要像显示的参数那样.

到目前为止,我可以获得授权的DriveService:

drive = Google::Apis::DriveV3::DriveService.new
drive.authorization = Google::Auth.get_application_default(['https://www.googleapis.com/auth/drive'])
Run Code Online (Sandbox Code Playgroud)

我可以得到一个文件:

file_id = 'string-of-stuff'
file = drive.get_file file_id
Run Code Online (Sandbox Code Playgroud)

我可以在File对象上设置看起来没问题的属性:

file.update!(name: 'My new name')
Run Code Online (Sandbox Code Playgroud)

但是,我无法弄清楚如何在此之后让更新/补丁真正起作用.自述文件建议drive.update_file(file),但只是爆炸类型错误.

TypeError: Can't convert Google::Apis::DriveV3::File into String or Array.
Run Code Online (Sandbox Code Playgroud)

查看代码,#update_file实际上期望一个file_id作为第一个参数.

我已经尝试了基于README的各种变体,例如:

drive.update_file(file_id, {name: 'New name'})
Run Code Online (Sandbox Code Playgroud)

要么:

drive.update_file(file_id, {title: 'New name'})
Run Code Online (Sandbox Code Playgroud)

或(查看代码):

drive.update_file(file_id, fields: {title: 'New name'})
Run Code Online (Sandbox Code Playgroud)

甚至:

drive.update_file(file_id, file)
Run Code Online (Sandbox Code Playgroud)

爆炸与:

Google::Apis::ClientError: fieldNotWritable: The resource body includes fields which are not directly writable.
Run Code Online (Sandbox Code Playgroud)

但没有什么对我有用.有没有人用过这个图书馆?其他一切看起来都相当简单,但这只是很难.

ruby google-drive-api

3
推荐指数
1
解决办法
441
查看次数