- 我正在运行以下Jenkins文件
- 此Jenkins文件允许用户选择构建版本和质量等值
- 此Jenkins文件允许用户在产品安装过程中选择要选择的值,如应用程序(MSI文件,其中包含要选择的功能)
pipeline {
agent any
parameters {
choice(
name: 'version_choice',
choices: 'Trunk\nV25.0.0\nV24.0.0',
description: 'Select a version (Trunk or Release No.)')
choice(
name: 'quality_choice',
choices: 'latestGreen\nHotfix\nReleased\nInternal',
description: 'Select a quality')
choice(
name: 'protocol_choice',
choices: 'HTTPS',
description: 'Select Protocol, HTTPS (Secured) or HTTP (Non-Secured)')
booleanParam(
name: 'fuel',
defaultValue: false,
description: '')
booleanParam(
name: 'aloha_kitchen',
defaultValue: false,
description: '')
booleanParam(
name: 'data_event_publisher',
defaultValue: false,
description: '')
booleanParam(
name: 'catalog_exporter',
defaultValue: false,
description: '')
booleanParam(
name: 'signal_r',
defaultValue: false,
description: '')
booleanParam(
name: 'fiscal',
defaultValue: false,
description: '')
booleanParam(
name: 'notification_server',
defaultValue: false,
description: '')
choice(
name: 'eft_simulator_choice',
choices: ['MTX', 'EPS'],
description: 'Select EFT Simulator')
booleanParam(
name: 'external_services',
defaultValue: false,
description: 'Ext. Services Simulator')
}
stages {
stage('Initial') {
steps {
script {
APPLICATIONS = "";
if ("${params.fuel}" == "true") {
APPLICATIONS += ',Fuel';
}
if ("${params.aloha_kitchen}" == "true") {
APPLICATIONS += ',AlohaKitchen';
}
if ("${params.data_event_publisher}" == "true") {
APPLICATIONS += ',DataEventPublisher';
}
if ("${params.catalog_exporter}" == "true") {
APPLICATIONS += ',CatalogExporter';
}
if ("${params.signal_r}" == "true") {
APPLICATIONS += ',SignalR';
}
if ("${params.fiscal}" == "true") {
APPLICATIONS += ',Fiscal';
}
return APPLICATIONS;
}
}
}
stage('Revert Lab') {
steps {
dir("ansible") {
ansiblePlaybook (
[
inventory: '.../lab_r_mf.yml',
playbook: '.../ansible/playbooks/revert_vcenter_lab.yml',
installation: 'ansible',
colorized : true,
]
)
}
}
}
stage('Copy Files') {
stage('Copy Files') {
steps {
dir("ansible") {
ansiblePlaybook (
[
inventory: '.../lab_r_mf.yml',
playbook: '.../ansible/playbooks/copy_tfs_builds.yml',
installation: 'ansible',
colorized : true,
extraVars : [
version_choice: '${version_choice}',
quality_choice: '${quality_choice}'
]
]
)
}
}
}
stage('Center APP') {
steps {
dir("ansible") {
ansiblePlaybook (
[
inventory: '.../lab_r_mf.yml',
playbook: '.../ansible/playbooks/install_secured_center_primary_appserver.yml',
installation: 'ansible',
colorized : true,
extraVars : [
applications: "${APPLICATIONS}",
]
]
)
}
}
}
stage('Gateway') {
steps {
dir("ansible") {
ansiblePlaybook (
[
inventory: '.../lab_r_mf.yml',
playbook: '.../ansible/playbooks/install_secured_gateway.yml',
installation: 'ansible',
colorized : true,
extraVars : [
protocol_choice: '${protocol_choice}',
version_choice: '${version_choice}',
quality_choice: '${quality_choice}',
]
]
)
}
}
}
stage('app') {
steps {
dir("ansible") {
ansiblePlaybook (
[
inventory: '.../lab_r_mf.yml',
playbook: '.../ansible/playbooks/install_secured_app.yml',
installation: 'ansible',
colorized : true,
extraVars : [
applications: "${APPLICATIONS}",
]
]
)
}
}
}
stage('EFT. Sim.') {
parallel {
stage('MTX') {
when {
expression {
params.eft_simulator_choice == 'MTX'
}
}
steps {
dir("ansible") {
ansiblePlaybook (
[
inventory: '.../lab_r_mf.yml',
playbook: '.../ansible/playbooks/deploy_mtx_simulator.yml',
installation: 'ansible',
colorized : true,
extraVars : [
protocol_choice: '${protocol_choice}',
]
]
)
}
}
}
stage('EPS') {
when {
expression {
params.eft_simulator_choice == 'EPS'
}
}
steps {
dir("ansible") {
ansiblePlaybook (
[
inventory: '.../lab_r_mf.yml',
playbook: '.../ansible/playbooks/deploy_eps_simulator.yml',
installation: 'ansible',
colorized : true,
extraVars : [
version_choice: '${version_choice}',
quality_choice: '${quality_choice}',
protocol_choice: '${protocol_choice}',
]
]
)
}
}
}
}
}
}
}
- 由于网络问题或任何意外行为,管道经常会福尔斯。
- 尝试根据此Jenkins重新启动管道,显示如下错误消息:
groovy.lang.MissingPropertyException: No such property: APPLICATIONS for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:251)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:353)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:357)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:277)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
at jdk.internal.reflect.GeneratedMethodAccessor304.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:30)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:70)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Finished: FAILURE
- 此故障意味着Jenkins不知道“应用程序”变量。
- 我如何处理这个变量和其他变量(如$protocol_choice),使Jenkinsfile在任何阶段都“知道”这个变量及其选定的值?
1条答案
按热度按时间eyh26e7m1#
您要找的是Rebuilder插件。当您设定参数时,它会记住这些参数。当您想要重新执行工作时,您可以选择该工作,然后在左手窗格中会出现一个新的“重建”按钮,它会使用您之前使用的所有参数来启动工作。