jenkins - 如何使用bitbucket repo上的Json文件在Jenkinsfile.groovy中传递环境变量?
问题描述
我正在寻找一种解决方案,以使用 Jenkinsfile.groovy 从 Json 文件中传递 Jenkins 管道中的环境变量。json 文件存在于 bitbucket 存储库中。
我的 json 文件:
{"id" : "11245" }
詹金斯文件:
stage('Execution') {
windowsNode = 'any'
node(windowsNode) {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bitbucket-access', url:'http://stash.com']]])
withEnv([def props = readJSON file: 'project.json', 'ID': 'props['id']']){
stage('Build'){
bat 'python --version' }
echo 'executed'
}
}
}
但我收到错误:
java.lang.NullPointerException
at org.jenkinsci.plugins.workflow.steps.EnvStep.<init>(EnvStep.java:51)
Caused: java.lang.reflect.InvocationTargetException
解决方案
推荐阅读
- android - 无法使用颤振仅在 android Oreo sdk 27 上创建文件夹?
- vhdl - 为什么我选择的信号分配不起作用?
- php - Laravel - 无法从 .env 文件中获取 .pem 公钥数据
- c# - C# - System.Data.SqlClient.SqlException: '')' 附近的语法不正确。
- azure - 在 Azure AKS 中使用 Kubernetes Ingress 有哪些优势
- android - 使用 Jetifier 工具的 AndroidX 迁移将支持库转换为 RC 版本
- arrays - 数组添加未定义元素,角度 6
- regex - 插入空白值
- xaml - 在 Xamarin App 上使用 Font Awesome 会显示空白框而不是 UWP 上的图标
- python - 如何创建其他IP可以访问的网页(Python wsgiref.simple_server)