【问题标题】:Git pull on remote server using jenkins pipelineGit 使用 jenkins 管道拉取远程服务器
【发布时间】:2018-12-10 22:26:35
【问题描述】:

我有这个用于 git checkout 阶段,它工作正常

checkout([$class: 'GitSCM',
     branches: [[name: "*/master" ]],
     doGenerateSubmoduleConfigurations: false,
     extensions: [[$class: 'LocalBranch', localBranch: "**"]],
     submoduleCfg: [],
     userRemoteConfigs: [[credentialsId: env.GIT_CREDS, url: env.GIT_REPO]]
         ])

我正在尝试配置 jenkins 作业(使用 jenkins 管道)以使用 sshagent 在远程服务器上执行 git pull 我需要使用管道中定义的 GIT_CREDS 用于远程服务器上的 git pull 需要类似的东西:

sh "ssh ubuntu@$Ip 'git pull'" 

使用 GIT_CREDSGIT_REPO 环境变量

有人可以帮我解决这个问题

【问题讨论】:

    标签: git jenkins jenkins-pipeline ssh-agent


    【解决方案1】:

    只需使用 git

    git(
        url: 'git@git.com:YourGitRepo.git',
        credentialsId: '5ef933f28-bdb2-0563-bfc7-b460490262735', // found here http://jenkinsURL:8080/credentials/
        branch: 'master'
        )
    

    它在内部使用 ssh。
    希望对你有帮助:)

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2019-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-09
      • 2018-01-23
      相关资源
      最近更新 更多