jenkins yaml Jcasc触发器并轮询scm以自动添加作业

问题描述 投票:0回答:1

我有以下jenkins yaml,它可以工作并自动放入作业。它不会添加凭据,除非我进入UI并选择相同的ID“ github”,或者允许我添加轮询或触发

我尝试了多种组合,它们会使部署崩溃或完全不添加作业。

triggers {
    pollSCM 'H/10 * * * *'
}

triggers {
    cron (H/10 * * * *)
}

我想添加cron和poll scm,因为作业是手动运行的,它是从回购jenkinsfile中拾取的

jenkins:
  systemMessage: "CTOPsJenkins: configured automatically with JCasC plugin\n\n"
tool:
  git:
    installations:
    - home: "git"
      name: "Default"
jobs:
  - script: >
      pipelineJob('my_pipleline_build') {
          definition {
              cpsScm {
                  scriptPath 'Jenkinsfile'
                  scm {
                    git {
                        remote { url 'https://github.com/my_pipleline_build.git' }
                        branch '*/master'
                        credentials: ('github')
                        extensions {}
                    }
                  }
              }
          }
      }
  - script: >
      pipelineJob('my_other_pipleline_build') {
          definition {
              cpsScm {
                  scriptPath 'Jenkinsfile'
                  scm {
                    git {
                        remote { url 'https://github.com/cloud/my_other_pipleline_build.git' }
                        branch '*/my_pipleline_build'
                        credentials: ('github')
                        extensions {}
                    }
                  }
              }
          }
      }
jenkins jenkins-groovy jenkins-cli jenkins-job-dsl jcasc
1个回答
0
投票

我能够在下面实现使用,

- script: >
  pipelineJob('my_other_pipleline_build') {
      definition {
          cpsScm {
              scriptPath 'Jenkinsfile'
              scm {
                git {
                    remote { url 'https://github.com/cloud/my_other_pipleline_build.git' 
                    credentials('github')
                    }
                    branch '*/my_pipleline_build'
                    extensions {}
                }
              }
          }
      }
  }
© www.soinside.com 2019 - 2024. All rights reserved.