I just want to run service container in the pipeline conditionally similar to using when condtion in pipeline step.
Here basically here I have when condition to the step. In addition I need one for services part, if that make sense.
The use case would be, I want to use same build pipeline yaml in some builds where we don’t use db container in integration testing but H2 in-memory DBs.
So in those cases services section is not needed.
If that make sense.
Personally I believe that db testing should be as close to production. Is the real application actually using H2 in production? Or does it use Mysql/Postgresql/Oracle?
It is best to always use the same db as production.
To do what you want I would probably use two separate pipelines. Or a parent pipeline that calls a child one.
This is for build pipeline system testing. Due to cloud restriction and costing unable to use prod like db.(Oracle )
So was thinking use same yaml with options like depend on/when/if etc. conditional approach if possible.
BTW, I found this in chat gpt, does this make sense?
version: '1.0'
steps:
myStep:
image: my-image:latest
when:
condition:
equals:
- ${{CF_BRANCH}}
- 'master' # Change this condition to your desired criteria
services:
myService:
image: my-service-image:latest
I strongly suggest to setup a second “staging” Oracle instance for testing stuff. This would also be useful for SQL updates (and not just source code). Using H2 to “replace” Oracle might work for simple stuff only.