简体   繁体   English

使用管道脚本将签入 github 的文件下载到 Jenkins 工作区

[英]Download a file checked into github into Jenkins workspace using pipeline script

I am trying to download a file which is checked into github into Jenkins workspace.我正在尝试将已签入 github 的文件下载到 Jenkins 工作区中。 But its throwing error saying 'failed writing body (0.= 1364)'?但是它的抛出错误说'写入正文失败(0.= 1364)'? how can download a file from github to jenkins workspace?如何将文件从 github 下载到 jenkins 工作区? Appreciate any solution on this?对此有任何解决方案吗?

stage('Download github file ')
{
 steps{
    script{
        sh'''
         curl -H github-ssh-key -o $WORKSPACE -L 'https://github.com/<repo>/blob/1.2.0/test.csv'
      '''               
      }
  }

} }

Here is some Groovy code, you can use to download a specific file from a Private repo.这是一些 Groovy 代码,您可以使用它从 Private repo 下载特定文件。 First, you need to generate a GitHub access token that can be used.首先,您需要生成一个可以使用的 GitHub 访问令牌。

def accessToken = "ACCESS_TOKEN".bytes.encodeBase64().toString()
def get = new URL("https://raw.githubusercontent.com/xxxx/something/hosts").openConnection();
get.setRequestProperty("authorization", "Basic " + accessToken)
def content = get.getInputStream().getText()

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

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