Aron
Aron

Reputation: 391

How do I remove the implict 'checkout' task from Bamboo YAML

I am using the Bamboo build system to create and deploy a docker image. I have three stages corresponding to:

  1. Build Docker Image
  2. Tag Image
  3. Deploy Image

In the build stage I am pulling my Dockerfile, and any other dependencies I need to construct the image from git. Then I am building the docker image, which is stored in my local repository.

In the tag and deploy stages, I am performing the obvious tasks using the docker image stored in the build stage.

There is no need to checkout source code in the last two stages- and in fact it should be avoided for various reasons.

Question: Is there a way to avoid having bamboo perform this code checkout in the last two steps?

Leaving the checkout task out of my bamboo.yml is not effective, as bamboo implicitly adds it back in. The best I can seem to do is add the force-clean-build tag set to false, like so:

- checkout:
      force-clean-build: 'false'

Upvotes: 1

Views: 1404

Answers (2)

Xiangkun
Xiangkun

Reputation: 1107

If there are no needs for checkout in all jobs, an empty list of repositories can be specified in the top level of the bamboo YAML spec to remove the implicit checkout task.

repositories: []

Note that this works only when updating an existing plan; to create a new plan, a non-empty repositories field is still required (implicitly defined repositories will do as well), though it can be set to an empty array once the plan is created.

Otherwise, the following error will occur:

Plan PROJECT-PLAN doesn't have default repository

java.lang.IllegalStateException: Plan PROJECT-PLAN doesn't have default repository

Upvotes: 0

Oleksiy Chystoprudov
Oleksiy Chystoprudov

Reputation: 1145

Bamboo requires at least one checkout task for job. If you don't need repo checkout try to trick Bamboo with conditional checkout task

  tasks:
  - checkout:
      repository: you-repo
      conditions:
      - variable:
          exists: my.var

Upvotes: 5

Related Questions