简体   繁体   English

Salt堆栈中是否有文件上传功能,可以将罐子上传到JFrog Artifactory?

[英]Is there a file upload function in salt stack to upload a jar to JFrog Artifactory?

I am using saltstack state script to create a jar from BitBucket and upload the jar to Artifactory. 我正在使用saltstack状态脚本从BitBucket创建一个jar,并将其上传到Artifactory。 When uploading to Artifactory I see an authorization error. 上传到Artifactory时,我看到授权错误。 I am not sure if this is the right approach to achieve the upload to Artifactory. 我不确定这是否是实现上传到Artifactory的正确方法。

I tried using CURL to achieve upload. 我尝试使用CURL实现上传。 I need to provide -u myUser:myPassword along the CURL command for it to work. 我需要在CURL命令中提供-u myUser:myPassword才能使其正常工作。 I cannot provide the credentials in my salt state scripts. 我无法在盐状态脚本中提供凭据。 I am looking for a better option to achieve the upload without using login credentials. 我正在寻找一个更好的选项来实现不使用登录凭据的上传。 How to upload artifacts to artifactory using saltstack? 如何使用Saltstack将工件上传到工件?

curl -X PUT -T /tmp/Batch.jar http://artifactory/artifactory/Batch.jar

Error: stdout: 错误:stdout:

              {
                \"errors\" : [ {
                  \"status\" : 401,
                  \"message\" : \"Unauthorized\"
                } ]
              }

According to Artifactory documentation , the REST API supports these forms of authentication: 根据Artifactory文档 ,REST API支持以下身份验证形式:

  • Basic authentication using your username and password 使用您的用户名和密码进行基本身份验证
  • [Simplest] Basic authentication using your username and API Key. [最简单]使用您的用户名和API密钥进行基本身份验证。
  • Using a dedicated header ( X-JFrog-Art-Api ) with your API Key. 通过API密钥使用专用标头( X-JFrog-Art-Api )。
  • Using an access token instead of a password for basic authentication. 使用访问令牌代替密码进行基本身份验证。
  • [Recommended] Using an access token as a bearer token in an authorization header [推荐]在授权标头中使用访问令牌作为承载令牌
    ( Authorization: Bearer ) with your access token. Authorization: Bearer )以及您的访问令牌。

You will have to choose one of the above. 您将不得不选择以上之一。

I've run into this sort of thing a couple of times. 我已经遇到过几次这样的事情。 The easiest solution is to write a small salt execution module to do this work. 最简单的解决方案是编写一个小的Salt执行模块来完成这项工作。 This way you can store the artifactory credentials as pillar data and use the normal python requests or salt http helpers to make the web requests. 这样,您可以将人工凭证存储为支​​柱数据,并使用常规的python请求或salt http帮助程序进行Web请求。

Looks like salt stack provides a module for artifactory alread: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.artifactory.html 看起来盐堆为已有的人工制品提供了一个模块: https ://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.artifactory.html

It may not do exactly what you're looking for, but you could definitely extend it: https://github.com/saltstack/salt/blob/develop/salt/modules/artifactory.py 它可能无法完全满足您的要求,但是您可以扩展它: https : //github.com/saltstack/salt/blob/develop/salt/modules/artifactory.py

The saltstack docs for writing execution modules can be here: https://docs.saltstack.com/en/latest/ref/modules/ 用于编写执行模块的saltstack文档可以在这里: https ://docs.saltstack.com/en/latest/ref/modules/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM