问题描述
我正在使用位于git存储库中的Jenkins文件.我已经使用指向sjenkinsfile的scm的管道脚本配置了新作业.我试图在我的Jenkins文件管道脚本中使用git模块,以便从我的git存储库中提取数据,而无需配置pre静态变量,而只是使用已在scm中配置的scm在管道脚本下使用存储库URL的变量我的工作 .有一种方法可以获取变量存储库URL 从该插件中获取,而无需在我的Jenkins管道脚本中使用参数.
我已经尝试过环境变量 GIT_URL 和其他与
您可以在 scm
变量中找到有关scm的所有信息(实例为 GitSCM (如果您使用的是git).您可以通过这种方式获取存储库URL
def repositoryUrl = scm.userRemoteConfigs [0] .url
但是,如果您只想检出该存储库,则可以简单地调用 checkout scm
,而无需指定其他任何内容.请参见结帐步骤
i'm using Jenkins file that located in my git repository.I have configured new job using the pipeline script from scm that point to my jenkinsfile. I'm trying to use in my Jenkins file pipeline script the git module in order to pull my data from my git repo without configure pre static variable and just to use the variable of the repository URL under pipeline script from scm that already was configured in my job .There is a way to get somehow the variable Repository URLfrom this plugin without using parameters in my Jenkins pipeline script.
I have already tried the environment variable GIT_URL and other stuff that related to git from here but this didn't work.
You can find all information about scm in scm
variable (instance of GitSCM if you are using git).You can get repository URL this way
def repositoryUrl = scm.userRemoteConfigs[0].url
But if you just want to checkout that repository you can simply invoke checkout scm
without needing to specify anything else. See checkout step
这篇关于jenkins管道从scm获取管道脚本下的存储库URL变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!