run:
name: update command: |
my command …<< parameters.kafka >> <— I would like to exacute this command 2 times for kafka_addr1 , kafka_addr2, executing one build “build_pr”
You’re on the right track here, and I would be happy to assist you further with this. This looks like a snippet for your configuration, so I may be missing some information on how this job is defined, but I’ll try and make this example as clear as possible. Please let me know if you require any clarification.
The job containing the parameter kafka should be defined as a reusable command syntax.
version: 2.1
commands:
run-kafka-command: # This is just a name, I encourage this to be changed!
parameters:
kafka:
type: string
default: "kafka_addr"
steps:
- run: echo << parameters.kafka >> #...command as you already have included
From your snippet, it looks like you have this part complete. The error here is likely how the command is being called. This is how we can run the command twice in the build job.
jobs:
build-pr:
docker:
- image: cimg/node # Please continue using the image of your choice!
steps:
- run:
command: "echo Hello!"
- run-kafka-command:
kafka: "foo"
- run-kafka-command:
kafka: "boo"
workflows:
build-test:
jobs:
- build-pr:
filters:
branches:
ignore: master
As you can see, we call the command twice within the build-pr job, and then only call the build-pr job later. Once you make your changes, run circleci config validate to see if everything compiled properly. If you run into any trouble at this stage, please feel free to reply with any errors that crop up.
I hope this helps you with your building adventure!