jenkins管道中的cURL请求带有隐藏的令牌和密钥

时间:2017-04-27 14:54:27

标签: curl jenkins sh access-token jenkins-pipeline

我试图找到一种更好的方法来使用curl请求运行远程jenkins作业。

我目前的管道设置如下:

parallel firstBranch: {
    build 'erp_load'
  },
    secondBranch: {
    build 'erp_load2'
  },
    thirdBranch: {
    build 'erp_load3'
  }
  failFast: true

node {
    sh 'curl -X POST http://user:xxxkeyxxx@remote_host.com/job/flow_one/build?token=\'xxxtokenxxx\''
}

但是我希望找到一种更好的方法来执行此cURL请求,而无需在其中明确写入我的令牌和密钥。

我现在正在做的一种方法是构建一个调用我的凭证库的python脚本,并使用os模块运行shell命令,如下所示:

import os
import credentials

os.system('curl -X POST http://user:{0}@remote_host.com/job/flow_one/build?\
token=\'{1}\''.format(credentials.key,credentials.token))

我想知道是否有可能直接在jenkins中执行此操作而不会影响调用的键和令牌元素,并且不使用像python中的脚本那样的其他工作流程。

0 个答案:

没有答案
相关问题