Hey all!
I’m just starting to learn CI pipelines, and came across a weird behavior.
The idea is that I want different push_bits behavior depending on the branch type. RIght now, the only difference is the path to upload to, but I plan on having other behavior later.
However, when I use the .gitlab-ci.yml (sanitized) below, pushing a new merge request branch creates two pipelines - One running build and test, the other running push_bits. I want push_bits to run only after test has successfully completed. What’s going on?
Also, I’m new to this, so if you see any other glaring errors or better ways to accomplish what I want, let me know.
Thanks!
image: "hseeberger/scala-sbt:8u141-jdk_2.12.3_1.0.2"
variables:
SBT_OPTS: "-Dsbt.global.base=sbt-cache/sbtboot -Dsbt.boot.directory=sbt-cache/boot -Dsbt.ivy.home=sbt-cache/ivy -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=2G -Xmx2G -Xss4M"
PROJECT_JAR_NAME: "project.jar"
PROJECT_MERGEREQUESTS_JAR_FOLDER: "s3://bucket/path/mergerequests"
PROJECT_SNAPSHOT_JAR_FOLDER: "s3://bucket/path/snapshots"
PROJECT_RELEASES_JAR_FOLDER: "s3://bucket/path/releases"
PROJECT_PRODUCTION_JAR_FOLDER: "s3://bucket/path/prod"
cache:
untracked: true
paths:
- "sbt-cache/ivy/cache"
- "sbt-cache/boot"
- "sbt-cache/sbtboot"
- "sbt-cache/target"
before_script:
#aws cli requires pip, which requires python, which the image does not have
- apt-get install python
- curl -O https://bootstrap.pypa.io/get-pip.py
- python get-pip.py --user
- export PATH=~/.local/bin:$PATH
- pip install awscli # Install aws
stages:
- build
- test
- push_bits
build_all:
stage: build
script:
- sbt compile
test_all:
stage: test
script:
- sbt test
push_bits_merge_request:
stage: push_bits
only:
- merge_requests
script:
- sbt assembly
- aws s3 cp /builds/company/project/target/scala-2.11/project-assembly-0.1.jar ${PROJECT_MERGEREQUESTS_JAR_FOLDER}/${CI_COMMIT_REF_NAME}/${PROJECT_JAR_NAME}
push_bits_master_snapshot:
stage: push_bits
only:
- master
script:
- sbt assembly
- aws s3 cp /builds/company/project/target/scala-2.11/project-assembly-0.1.jar ${PROJECT_SNAPSHOT_JAR_FOLDER}/${CI_COMMIT_SHA}/${PROJECT_JAR_NAME}
push_bits_release:
stage: push_bits
only:
- /^release-regex$/
script:
- sbt assembly
- aws s3 cp /builds/company/project/target/scala-2.11/project-assembly-0.1.jar ${PROJECT_RELEASES_JAR_FOLDER}/${CI_COMMIT_SHA}/${PROJECT_JAR_NAME}