将变量从Octopus项目导出到json文件 [英] Export variables from Octopus project to json file

查看:78
本文介绍了将变量从Octopus项目导出到json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Jenkins中的命令"步骤将章鱼变量导出到json文件? 根据八达通官方文件,我只能导出项目和版本.

有什么方法可以从特定项目中导出特定变量?

解决方案

当前,您不能使用章鱼REST API . /p>

首先,您必须创建一个 API密钥,这是访问这些API所必需的. 然后调用以下API端点以获取您的特定项目.

https://<your-octopus-installation>/api/projects/<project name>

然后,响应JSON包含VariableSetId,您应将其用于以下请求.

https://<your-octopus-installation>/api/variables/<VariableSetId>

对于上述每个请求,您都应提供X-Octopus-ApiKey HTTP标头,并将API密钥作为值.有关更多详细信息,请参考.

请注意,您不会获得敏感变量的值.

提示: 通过浏览器访问八达通时,请注意其执行的HTTP请求.这将帮助您了解需要执行的API调用,以实现您的要求.

如果您使用C#,可以尝试 Octopus.Client

Is there any way to export Octopus variables to json file, using "Command" step in Jenkins? According to official Octopus documentation I only able to export Projects and Releases.

Is there any way to export particular variables from particular project?

解决方案

Currently you can not do this using Octo.exe.

However you can still use Octopus REST API for your purpose.

First you have to create a API Key, which is required to access those APIs. Then call following API end point to get your specific project.

https://<your-octopus-installation>/api/projects/<project name>

Then response JSON contains VariableSetId which you should use for following request.

https://<your-octopus-installation>/api/variables/<VariableSetId>

For each of the above requests you should provide X-Octopus-ApiKey HTTP header with the API key as the value. Please refer this for more details.

Please note that you won't get the values of sensitive variables.

Tips: When you access the Octopus via browser, observe the HTTP requests it perform. That will helps you to understand, API calls that needs to be performed, to achieve your requirement.

If you are in to C# you can try Octopus.Client

这篇关于将变量从Octopus项目导出到json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆