2

我有一个用于声明性管道的 groovy 脚本。我必须通过 GUI 继续添加变量和单选按钮选项,我想知道是否有办法使用该parameters块编写脚本?这是GUI部分;

在此处输入图像描述

脚本如下所示;

stage('Notifications Receiver (dev)') {
      steps {
        script {
            taskDefinitionFamily = "mis-core-dev-notifications-receiver"
            taskDefinition = "mis-core-dev-notifications-receiver-a"
            taskFilterName = "mis-core-dev-notifications-receiver-"
            tasksGroup = "mis-core-dev-notifications-receiver-a,mis-core-dev-notifications-receiver-b"
            if (params.notificationsReceiver.contains('Stop Task')) {
            build(job: 'Stop ECS Task (utility)',
            parameters: [
            string(name: 'region', value: params.region),
            string(name: 'cluster', value: params.cluster),
            string(name: 'family', value: taskDefinitionFamily)
            ])
          }
            else if (params.notificationsReceiver.contains('Start Task')) {
            build(job: 'Start ECS Task (utility)',
            parameters: [
            string(name: 'region', value: params.region),
            string(name: 'cluster', value: params.cluster),
            string(name: 'taskDefinition', value: taskDefinition),
            string(name: 'containerInstanceIds', value: params.containerInstanceIdsToStartOn)
            ])
          }
            else if (params.notificationsReceiver.contains('Restart Task')) {
            build(job: 'Hot Reload (utility)',
            parameters: [
            string(name: 'region', value: params.region),
            string(name: 'cluster', value: params.cluster),
            string(name: 'taskFilterName', value: taskFilterName),
            string(name: 'tasksGroup', value: tasksGroup),
            string(name: 'containerInstanceIdsToStartOn', value: params.containerInstanceIdsToStartOn)
            ])
          }
            else if (params.notificationsReceiver == null || params.notificationsReceiver == "") {
            echo "Did you forget to check a box?"
          }
        }
      }
    }
4

0 回答 0