相关疑难解决方法(0)

如何在github组织Jenkins工作流中检出ssh remote并在Jenkinsfile中使用ssh凭据

Github Organisation在詹金斯有一个项目.在我的存储库的根目录中,我Jenkinsfile看起来像这样:

node {

  def jenkinsCredsId = 'xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb'

  stage 'Checkout'
  checkout scm
  // I also tried the following:
  // checkout scm: [$class: 'GitSCM', source: 'ssh://git@github.com:MY_ORGANISATION/jenkins-testing-temp.git', clean: true, credentialsId: jenkinsCredsId]

  stage 'Build'
  // generate some artefact (dist.zip)

  stage 'Release'

  sshagent([jenkinsCredsId]) {
    sh '''
    git remote -v // show remotes
    ssh-add -l // show currently loaded ssh keys fingerprints

    git fetch --all --tags // IT FAILS HERE

    CURRENT_BUILD_TAG="some_build/${BUILD_NUMBER}"
    git tag ${CURRENT_BUILD_TAG}

    git push --tags

    github-release release \
    --security-token …
Run Code Online (Sandbox Code Playgroud)

git github jenkins github-organizations jenkins-pipeline

7
推荐指数
1
解决办法
4016
查看次数