diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3aa7957564793b170dfd6c840cbf310e6b792602..84c0a9d28040505f126206f9660d74a33c5a1c82 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,6 @@ variables: DATA_CONUS_2018A: conus-2018a DATA_URL: ${S3_BUCKET}/nshmp_2018a_v1.1-CONUS-hazards-with-preliminary-PGV-fv0.3-1x1.nc - GRADLE_USER_HOME: ${CI_PROJECT_DIR}/tmp/.gradle - JACOCO_HTML_DIR: ${REPORTS_DIR}/jacoco/test/html - JUNIT_FILES: build/test-results/test/TEST-*.xml - REPORTS_DIR: build/reports # TODO: Remove hard coded url S3_BUCKET: https://nshmp-netcdf-lp-development-rbucket-1of3d1x45yfd9.s3-us-west-2.amazonaws.com @@ -16,9 +12,9 @@ workflow: - if: $CI_COMMIT_BRANCH include: - - project: "ghsc/hazdev/pipeline-build-template" - ref: "1.1.3" - file: "templates/library.yml" + - project: 'ghsc/nshmp/nshmp-pipeline-templates' + ref: 'main' + file: 'templates/library.yml' stages: - init @@ -88,64 +84,26 @@ stages: #### Init: - artifacts: - paths: - - '${GRADLE_USER_HOME}' extends: - - .gradle - script: - - ./gradlew dependencies - stage: init + - .gradle-init #### # Stage: build #### -.docker-build: - image: ${DEVOPS_REGISTRY}docker:19.03-git - script: - - BUILD_ARGS=''; - - | - for arg in ${DOCKER_BUILD_ARGS}; do - BUILD_ARGS="${BUILD_ARGS} --build-arg ${arg}"; - done - - | - docker build \ - ${BUILD_ARGS} \ - --pull \ - --tag "${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${IMAGE_TAG}" \ - --file "${CI_PROJECT_DIR}/${DOCKERFILE}" \ - "${CI_PROJECT_DIR}/."; - - docker push "${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${IMAGE_TAG}"; - - | - if [[ \ - ${CI_COMMIT_REF_SLUG} == "master" || \ - ${CI_COMMIT_REF_SLUG} == "production" || \ - -n "${CI_COMMIT_TAG}" \ - ]]; then - docker tag "${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${IMAGE_TAG}" \ - "${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:latest"; - docker push "${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:latest"; - docker tag "${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:latest" \ - "usgs/${CI_PROJECT_NAME}:latest"; - docker push "usgs/${CI_PROJECT_NAME}:latest"; - fi - - | - printf " - -------- - Image Name - %s:%s - -------- - " "${CI_PROJECT_NAME}" "${IMAGE_TAG}"; - services: - - alias: docker - name: ${DEVOPS_REGISTRY}docker:19.03-dind - stage: build - tags: - - build +Build Image 2018: + before_script: + - apk add curl + - mkdir DATA + - curl -SL ${DATA_URL} -o DATA/data.nc + extends: + - .docker-build variables: - DOCKERFILE: Dockerfile - DOCKER_DRIVER: overlay2 - IMAGE_TAG: ${CI_COMMIT_REF_SLUG} + DOCKER_BUILD_ARGS: | + BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/java:11 + FROM_IMAGE=${DEVOPS_REGISTRY}usgs/java:11 + ci_job_token=${CI_JOB_TOKEN} + netcdf_file=DATA/data.nc Build Project: extends: @@ -165,51 +123,6 @@ Build Project: - ./gradlew assemble stage: build -Build Image 2018: - before_script: - - apk add curl - - mkdir DATA - - curl -SL ${DATA_URL} -o DATA/data.nc - extends: - - .docker-build - needs: [] - rules: - - if: $CI_PROJECT_PATH != 'ghsc/nshmp/nshmp-netcdf' - variables: - IMAGE_TAG: 'development-${CI_COMMIT_SHORT_SHA}' - - if: > - $CI_PROJECT_PATH == 'ghsc/nshmp/nshmp-netcdf' - && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - variables: - IMAGE_TAG: 'staging-${CI_COMMIT_SHORT_SHA}' - - if: > - $CI_PROJECT_PATH == 'ghsc/nshmp/nshmp-netcdf' - && ( $CI_COMMIT_BRANCH == 'production' || $CI_COMMIT_TAG != '' ) - variables: - IMAGE_TAG: 'production-${CI_COMMIT_SHORT_SHA}' - variables: - DOCKER_BUILD_ARGS: | - BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/java:11 - FROM_IMAGE=${DEVOPS_REGISTRY}usgs/java:11 - ci_job_token=${CI_JOB_TOKEN} - netcdf_file=DATA/data.nc - -Build Latest Image: - extends: - - .docker-build - needs: [] - rules: - - if: > - $CI_PROJECT_PATH == 'ghsc/nshmp/nshmp-netcdf' - && ( $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == 'production' ) - variables: - DOCKER_BUILD_ARGS: | - BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/java:11 - FROM_IMAGE=${DEVOPS_REGISTRY}usgs/java:11 - ci_job_token=${CI_JOB_TOKEN} - netcdf_file=DATA/data.nc - IMAGE_TAG: 'latest' - Unit Tests: artifacts: paths: