Build.yml
stages:
- build
.build_template:
stage: build
image: $CI_REGISTRY/$CI_PROJECT_PATH/nextgen-app:$APP_TAG
before_script:
- |
{
echo "@paloma:registry=${CI_API_V4_URL}/projects/81777/packages/npm/"
echo "${CI_API_V4_URL#https?}/projects/81777/packages/npm/:_authToken=${CI_JOB_TOKEN}"
} | tee -a .npmrc
- pnpm config set store-dir .pnpm-store
- pnpm i
script:
- echo "Building ${PACKAGE_NAME}"
- pnpm --filter="${PACKAGE_NAME}" run build
artifacts:
name: "$CI_JOB_ID"
paths:
- apps/${PACKAGE_NAME}/.next/*
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- changes:
- "apps/${PACKAGE_NAME}/**/*"
- "packages/ui-packages/${PACKAGE_NAME}/**/*"
coverage: '/All files[^|]*|[^|]*s+([d.]+)/'
build_article_micro_frontend:
extends: .build_template
variables:
PACKAGE_NAME: article-micro-frontend
build_category_micro_frontend:
extends: .build_template
variables:
PACKAGE_NAME: category-micro-frontend
publish.yml
stages:
- publish
.publish: &publish
stage: publish
image: $ARTIFACTORY/docker
variables:
HARBOR_PROJECT: "eait"
IMAGE_REPOSITORY: "harbor.darkside.ea.com/$HARBOR_PROJECT"
services:
- name: $ARTIFACTORY/docker:dind
before_script:
- |
{
echo "@paloma:registry=${CI_API_V4_URL}/projects/81777/packages/npm/"
echo "${CI_API_V4_URL#https?}/projects/81777/packages/npm/:_authToken=${CI_JOB_TOKEN}"
} | tee -a .npmrc
- if [[ $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH ]] ; then export TAG='latest' ; else export TAG=$CI_COMMIT_REF_NAME ; fi
- if [[ $CI_COMMIT_TAG ]] ; then export TAG=$CI_COMMIT_TAG ; fi
- mkdir -p ~/.docker
- echo '{"auths":{"'$IMAGE_REPOSITORY'":{"username":"'$HARBOR_USER'","password":"'$HARBOR_PASSWORD'"}}}' >> ~/.docker/config.json
tags:
- ceit-dind
# Image for article-micro-frontend
publish:article-micro-frontend:
<<: *publish
needs:
- build_article_micro_frontend
script:
- export IMAGE_NAME=article-micro-frontend
- export REPO="$IMAGE_REPOSITORY/$IMAGE_NAME"
- docker build --file apps/article-micro-frontend/Dockerfile -t $REPO:$CI_PIPELINE_ID .
- docker push $REPO:$CI_PIPELINE_ID
# Image for category-micro-frontend
publish:category-micro-frontend:
<<: *publish
needs:
- build_category_micro_frontend
script:
- export IMAGE_NAME=category-micro-frontend
- export REPO="$IMAGE_REPOSITORY/$IMAGE_NAME"
- docker build --file apps/category-micro-frontend/Dockerfile -t $REPO@$CI_PIPELINE_ID .
- docker push $REPO@$CI_PIPELINE_ID
I am using the needs
keyword to depend on previous job but getting this error:
'publish:article-micro-frontend' job needs 'build_article_micro_frontend' job, but 'build_article_micro_frontend' is not in any previous stage
'publish:category-micro-frontend' job needs 'build_category_micro_frontend' job, but 'build_category_micro_frontend' is not in any previous stage
What did I miss? Please help