0

I'm trying to auto-bump npm project's version via GitLab. This is my gitlab CI:

stages:
  - release

variables:
  project_name: yagelProjectTest
  SEMANTIC_RELEASE_PACKAGE: ${project_name}
  CI_REPOSITORY_URL: https://release-user:glpat-xxxxxxxxx@gitlab.com/pro/ject/blalba.git

release:
  image: node:latest
  stage: release
  script:
    - export PUSH_REPO=$(echo "$CI_REPOSITORY_URL" | sed -e "s|.*@\(.*\)|git@\1|" -e "s|/|:/|" )
    # increment PATCH, for instance
    - git config --global user.email "yagel@aaaaa.com"
    - git config --global user.name "yagel"
    - git branch
    - git checkout "${CI_COMMIT_BRANCH}"
    - echo "${CI_COMMIT_BRANCH}"
    - git branch
    - npm version minor
    - git remote add origin-ci "${PUSH_REPO}"
    - git pull
    - git add .
    - git commit -m "auto-increment"
    - git push origin-ci "${CI_COMMIT_BRANCH}"

This is the error I'm getting:

$ npm version minor
v0.1.0
$ git remote add origin-ci "${PUSH_REPO}"
$ git pull
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Already up to date.
$ git add .
$ git commit -m "auto-increment"
On branch yagel-auto-bump
Your branch is ahead of 'origin/yagel-auto-bump' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

Any idea why I'm getting this error?

Yagel
  • 1,184
  • 2
  • 18
  • 41
  • If you were clean and up-to-date/behind at pull time, I don't think you should have gotten that error. Did that branch have a new commit *before* the `pull`? What version of git is the ci tool running? Also, decide if you expect to ever possibly be ahead or not. It you should always be behind or up-to-date, try `git pull --ff-only`, if you might have a new commit, you could try `git pull --rebase` and/or `git pull --no-rebase`. – TTT Mar 14 '23 at 21:04
  • Also, see this [question](https://stackoverflow.com/q/62653114/184546) for more details about your options. This may possibly end up being a dup. – TTT Mar 14 '23 at 21:10

0 Answers0