Hi,
is it possible to have the maven command set using conditionals?
something like this (not working example)
version: 2.1
orbs:
maven: circleci/maven@1.2
workflows:
maven_test:
jobs:
- maven/test:
when:
condition:
equal: [ master, << pipeline.git.branch >> ]
command: deploy
unless:
condition:
equal: [ master, << pipeline.git.branch >> ]
command: package
Hi @peringemar! Welcome to the CircleCI Discuss community!
What you’re trying to achieve is indeed possible, albeit with a different syntax.
You’d need to leverage the pre-steps
argument in order to dynamically set the value of the command
parameter you wish to pass to the maven/test
job.
I suggest the following configuration:
version: 2.1
orbs:
maven: circleci/maven@1.2
workflows:
maven_test:
jobs:
- maven/test:
command: $MAVEN_COMMAND
pre-steps:
- when:
condition:
equal: [ master, << pipeline.git.branch >> ]
steps:
- run: echo 'export MAVEN_COMMAND=deploy' >> $BASH_ENV
- unless:
condition:
equal: [ master, << pipeline.git.branch >> ]
steps:
- run: echo 'export MAVEN_COMMAND=package' >> $BASH_ENV
Let me know if you have any question.
(Edit: fixing job name typo)
Thank you, that helped a lot
1 Like
system
Closed
4
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.