【问题标题】:Despite skipDefaultCheckout true Jenkins still clones repository尽管 skipDefaultCheckout true J​​enkins 仍然克隆存储库
【发布时间】:2019-10-31 16:38:54
【问题描述】:

尽管使用了 skipDefaultCheckout true,它仍然会克隆 git 存储库。 我的目标只是寻找更改然后执行某些脚本。 我已经没有想法了。我试过这个How to use SkipDefaultCheckout in a scripted pipeline,但我怀疑它不起作用?

pipeline {
  agent any
  options {
    skipDefaultCheckout true
  }
   environment {
       branch = 'test'
   }
  stages {
    stage('commit_stage') {
      steps {
        script {
          properties([pipelineTriggers([pollSCM('*/5 * * * *')])])
          git branch: "${branch}", credentialsId: 'test', url: 'https://gitlab.test.net/core/test.git'
          sh '''
          branch=${branch}
          ssh bamboo@app-test.synchr.net "cd /opt/${branch}-8*/ && ./startup.sh status"
             '''
                }
          //define scm connection for polling

      }
    }
  }
}

【问题讨论】:

  • 选项skipDefaultCheckout 是为了防止在您没有在某个阶段明确定义签出步骤时在构建代理中自动签出存储库。但如果您没有在 来自 SCM 的管道脚本下选择 Lightweight checkout,它仍然会签出存储库以获取 Jenkinsfile。

标签: jenkins groovy jenkins-pipeline devops


【解决方案1】:

看起来您只是为该选项弄错了语法。你有:

  options {
    skipDefaultCheckout true
  }

应该是

  options {
    skipDefaultCheckout()
  }

Pipeline Syntax

【讨论】:

    猜你喜欢
    • 2022-11-10
    • 2021-10-18
    • 1970-01-01
    • 2021-12-31
    • 1970-01-01
    • 2020-01-14
    • 2011-06-09
    • 2013-12-08
    • 1970-01-01
    相关资源
    最近更新 更多