What I have so far
I have configured gitlab ci/cd pipeline for my project. So I have used base template which has 2 stages, build & package:
The build stage builds the project and creates a jar file. The package stage creates an image and store it in the container registry. A .gitlab-ci.yml file has been created.
image: docker:latest
services:
- docker:dind
stages:
- build
- package
build:
image: gradle:5.6.1-jdk11
stage: build
script:
- gradle clean build -x test
artifacts:
paths:
- build/libs/*.jar
package:
stage: package
script:
- docker build -t registry.gitlab.com/my-project/sample .
- docker login -u $CI_DOCKER_USERNAME -p $CI_DOCKER_PASSWORD registry.gitlab.com
- docker push rregistry.gitlab.com/my-project/sample
My problem
I don't want to trigger a build for all every branch. I want to trigger only in the development- and master-branch.
Is there anyway we can do that at project level instead of adding only in each stage?