0

I have to workflows into pipeline. I want my test and deploy pipelines to share the same steps but on top of this, I want to have extra steps into the deploy pipeline.

I tried to search for a solution and bumped into StackOverflow QA. Unfortunately, none of the suggestion worked. Also, most of them create extra work for the pipeline build and maintenance.

The config.yml looks the following way:

version: 2.1

do_stuff: &do_stuff
  steps:
    - checkout

    - run:
        mvn clean test

    - store_artifacts:
        path: htmlcov

    - store_test_results:
        path: test-results

jobs:

  build:
    docker:
      - image: circleci/openjdk:8-jdk

    <<: *do_stuff

  deployment:

    docker:
        - image: circleci/openjdk:8-jdk


    <<: *do_stuff

    steps:
      - run:
          mvn deploy

workflows:

  build-and-test-workflow:
    jobs:
      - build-and-test

  deployment-workflow:
    jobs:
      - deployment:
          requires:
            - build-and-test

My problem is that steps override steps from <<: *do_stuff reference and I cannot find an acceptable solution for usage references. The reason why I want solution look this way, mvn deploy should be strictly after reference and I don't want to duplicate pipelines. In the actual project, pipeline way more complicated.

Is there any way I can bypass this limitation of a yml syntax? Between, I am using pipeline if it makes any difference.

Dmytro Chasovskyi
  • 3,209
  • 4
  • 40
  • 82

1 Answers1

0

Unfortunately, I didn't find any solution to the above question.

I found a workaround, so deployment stage require other stages to execute first. It means that it is possible to generate files, attributes etc and use it later into the deployment stage.

It eliminates the need to duplicate parts of the workflow. To persist files from stage to stage into a workflow in Circle CI there is another answer on StackOverflow.

Dmytro Chasovskyi
  • 3,209
  • 4
  • 40
  • 82