Plugin:Git parameter
Important:
If you need use other type (other then branch) parameter, you must use git within checkout
Important settings:
- It should be set a default value because initial build must get this information
- Using git should be set a branchFilter as ‘origin/(.*)’ (origin is a Remote Server name)
Jenkins Pipeline:
/**
*Use Git parameter plugin to Adds ability to choose branches,
*tags or revisions from git repository configured in project.
*/
pipeline {
agent any
parameters {
gitParameter name: 'BRANCH_TAG',
type: 'PT_BRANCH_TAG',
branchFilter: 'origin/(.*)',
defaultValue: 'master',
selectedValue: 'DEFAULT',
sortMode: 'ASCENDING_SMART',
description: 'Select your branch or tag.'
}
stages {
stage('Example') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: "${params.BRANCH_TAG}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[url: 'https:/192.168.1.2/scm/test.git',credentialsId: 'for_gitlab',]]
])
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。