I have a pipeline to bump package.json version, build angular, and release it.
In the bump job I successfully increased my package version and push it into the master
in the next job which is build, the pipeline didn't pull the newest version, and doing build on the last one that I started the pipeline.
The question is, How can I pull the last commit that pushed by pipeline in the build job?
I have this pipeline:
stages:
- bump
- build
- release
bump:
stage: bump
image:
entrypoint: ['']
name: registry.gitlab.com/orgs/registries/node:16
only:
- tags
before_script:
# Clone the repository via HTTPS inside a new directory
- git clone "https://$GITLAB_USERNAME:$GITLAB_TOKEN@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "${CI_COMMIT_SHA}"
# Set the displayed user with the commits that are about to be made
- git config --global user.email "${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}"
- git config --global user.name "${GIT_USER_NAME:-$GITLAB_USER_NAME}"
script:
- cd "${CI_COMMIT_SHA}/path/to/angular/"
- npm version from-git
- git push origin "${CI_DEFAULT_BRANCH}" -o ci.skip
build:
stage: build
image: registry.gitlab.com/orgs/registries/php:7.4.29
only:
- tags
before_script:
- echo $CI_JOB_ID
# Writing GE_JOB_ID variable to environment file, will need the value in the next stage.
- echo GE_JOB_ID=$CI_JOB_ID >> build.env
- npm install -g @angular/cli
- npm install -g nx
- composer install
script:
- cd public/src/frontend/
- npm install --force
- echo "Building Angular app and Making Plugin"
- npm run build:all
- echo "Build finished"
- echo "Angular Files"
- ls -lah
- cd ../../../
- echo "Plugin Files"
- ls -lah
artifacts:
paths:
- release/file.zip
reports:
dotenv: build.env
tags:
- docker
- gce
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo 'running release_job'
- echo 'Previous Job ID is printed below'
- echo $GE_JOB_ID
needs:
- job: build
artifacts: true
release:
name: 'Release File $CI_COMMIT_TAG'
description: 'Created using the release-cli'
# tag_name is a mendatory field and can not be an empty string
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
assets:
links:
- name: 'Artifact'
url: 'https://gitlab.com/orgs/somerepo/-/jobs/${GE_JOB_ID}/artifacts/raw/release/file.zip'
only:
- tags