Skip to main content

GitLab

Project Creation

Branch Standards

Acro has established certain standards that we require every project to adhere to. These standards serve as guidelines for maintaining consistency and quality across all projects. Refer to the Git Branches Standards Confluence page by following the link provided: Git Branches Standards

CI/CD Configuration

Including a token in the CI/CD process is crucial for the project's CI/CD operations during tasks like composer install or npm install, which involve linting, testing, and project deployment. In frontend projects, the .gitlab-ci.yml file dynamically generates an .npmrc file, which relies on the provided token.

Generating the token

  1. Navigate to https://git.acromedia.com/groups/acromedia/-/settings/access_tokens
  2. Fill in the token details:
    • Token name: GESSO_NPM_TOKEN
    • Expiration date: Set an appropriate expiration date
    • Role: Reporter
    • Scopes: Select read_api and read_registry
  3. Click Create group access token
  4. Copy the generated token immediately (it won't be shown again)

Adding the token in the project's CI/CD settings

  1. Navigate to the Acro's GitLab and choose the desired project where you wish to add the variable.
  2. Click on the Settings tab on the sidebar.
  3. Click on the CI/CD tab on the sidebar.
  4. Under the Variables section, click on the Expand button.
  5. Click on the Add variable button.
  6. Fill in the details as follows:
Variable Configuration
  • Type: Variable (default)
  • Environments: All (default)
  • Flags: Expand variable reference and Mask variable
  • Key: GITLAB_API_TOKEN
  • Value: The token value which you've previously generated.

Referencing the token in the GitLab CI file

Once the token is added as a secret variable, it can be referenced in the .gitlab-ci.yml file as shown below:

Frontend project example:

before_script:
- |
{
echo "@acromedia:registry=https://git.acromedia.com/api/v4/projects/packages/npm/"
echo "${CI_API_V4_URL#https?}/packages/npm/:_authToken=\${GITLAB_API_TOKEN}"
echo "${CI_API_V4_URL#https?}/projects/:_authToken=\${GITLAB_API_TOKEN}"
echo "${CI_API_V4_URL#https?}/projects/1149/packages/npm/:_authToken=\${GITLAB_API_TOKEN}"
} | tee -a ~/.npmrc

Drupal project example:

before_script:
- composer config gitlab-token.git.acromedia.com ${GITLAB_API_TOKEN}
- composer config gitlab-domains git.acromedia.com
- composer config data-dir ${CI_PROJECT_DIR}/.tmp/.composer

When defining jobs include your before_script

#
# Include the before_script within your CI jobs.
#
install:
stage: build
before_script:
- *base-before-script
script:
- pnpm install

Troubleshooting

401 Unauthorized Error

If you encounter an error like this during CI/CD or local installation:

ERR_PNPM_FETCH_401  GET https://git.acromedia.com/api/v4/projects/1149/packages/npm/@acromedia/gesso-core/-/@acromedia/gesso-core-8.0.2.tgz: Unauthorized - 401

Common causes:

  • The token has expired
  • The token has been revoked
  • The token doesn't have the correct permissions
  • The token is invalid or corrupted
  • The token variable is not properly set in CI/CD settings

Solution:

  1. Go to https://git.acromedia.com/groups/acromedia/-/settings/access_tokens
  2. Check if the existing GESSO_NPM_TOKEN is expired or revoked
  3. If needed, revoke the existing token and generate a new one with the same configuration:
    • Role: Reporter
    • Scopes: read_api, read_registry
  4. Update the token value in your project's CI/CD variables (Settings > CI/CD > Variables)
  5. Re-run your build/install process

Note: Make sure the token variable name in your CI/CD settings matches exactly what's referenced in your .gitlab-ci.yml file.