question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

implement gitlab-ci-cli package

See original GitHub issue

I remove issue template because he is not quite suitable for request.

It is will be great have package for gitlab CI, i spend around 2 hours for searching right configuration, but don’t find any information and use workaround:

node_modules/.bin/commitlint --from=HEAD~$(git --no-pager rev-list master..HEAD --count)

I don’t known about right usage this. Please correct me if this is not a very good solution.

Link to gitlab CI environment variables: https://docs.gitlab.com/ce/ci/variables/README.html

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
S-Coylecommented, Aug 26, 2021

Struggled with this for a while, specifically trying to get GitLab CI to check all of the commits in the MR, not just latest.

The above suggestions didn’t quite work for me, but I seem to have a winning script which my CI triggers

#!/bin/bash

# Need to fetch origin so we can calculate the shas of the branches
git fetch origin

# Get the target & source branch shas using their names, which is provided by the CI job
export TARGET_BRANCH_SHA=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME)
export SOURCE_BRANCH_SHA=$(git rev-parse origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME)
echo "TARGET_BRANCH_SHA = " $TARGET_BRANCH_SHA
echo "SOURCE_BRANCH_SHA = " $SOURCE_BRANCH_SHA

# Now run commitlint using the standard conventional commit config
echo "Checking MR commit messages..."
npx commitlint -x @commitlint/config-conventional --from=${TARGET_BRANCH_SHA} --to=${SOURCE_BRANCH_SHA} --verbose

Hopefully it helps someone else who comes across this

1reaction
oupalacommented, Sep 6, 2021

I finally followed this piece of chunk.

Here is my working snippet to make commit linting work with GitLab CI/CD:

  script:
   - npm install
   - npx commitlint --from=master to=CI_BUILD_REF_NAME

Assuming you’re always merging to master (I can’t find the destination branch while merging).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial: Create and run your first GitLab CI/CD pipeline
This tutorial shows you how to configure and run your first CI/CD pipeline in GitLab. Prerequisites. Before you start, make sure you have:....
Read more >
The `.gitlab-ci.yml` file - GitLab Docs
To use GitLab CI/CD, you need: Application code hosted in a Git repository. A file called .gitlab-ci.yml in the root of your repository,...
Read more >
GitLab Release CLI tool
The GitLab Release CLI ( release-cli ) tool is a command-line tool for managing releases from the command line or from a CI/CD...
Read more >
GitLab CI/CD Examples
This page contains links to a variety of examples that can help you understand how to implement GitLab CI/CD for your specific use...
Read more >
GitLab CI/CD
Learn how to use GitLab CI/CD, the GitLab built-in Continuous Integration, Continuous Deployment, and Continuous Delivery toolset to build, test, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found