Skip to content

Issues Running cz bump in ci/cd pipeline #610

@courtneysprouse

Description

@courtneysprouse

Description

This is not necessarily a bug, I could definitely be doing something wrong. I followed this tutorial , but I'm getting this error

Tag 6.0.0 could not be found. 
Possible causes:
- version in configuration is not the current version
- tag_format is missing, check them using 'git tag --list'
Warning: Input is not a terminal (fd=0).
? Is this the first tag created? (Y/n)
                                        ? Is this the first tag created? (Y/n)
Traceback (most recent call last):
  File "/usr/local/bin/cz", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/commitizen/cli.py", line 401, in main
    args.func(conf, vars(args))()
  File "/usr/local/lib/python3.8/site-packages/commitizen/commands/bump.py", line 132, in __call__
    is_initial = self.is_initial_tag(current_tag_version, is_yes)
  File "/usr/local/lib/python3.8/site-packages/commitizen/commands/bump.py", line 75, in is_initial_tag
    is_initial = questionary.confirm("Is this the first tag created?").ask()
  File "/usr/local/lib/python3.8/site-packages/questionary/question.py", line 70, in ask
    return self.unsafe_ask(patch_stdout)
  File "/usr/local/lib/python3.8/site-packages/questionary/question.py", line 92, in unsafe_ask
    return self.application.run()
  File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 978, in run
    return loop.run_until_complete(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 8[85](https://nacho.striveworks.us/csprouse/gitlab-testing-ground/-/jobs/247806#L85), in run_async
    return await _run_async(f)
  File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 750, in _run_async
    result = await f
EOFError

when I run cz bump in my ci-cd.yaml script even though I have an almost exact copy of the script suggested. I get this error because it's running in a novel environment, but I dont know how to fix it since that will happen everytime I execute my ci/cd yaml. I tried a few things to make it non interactive or to pipe the yes because I think it would work if I could say yes. But none of those things worked. Any suggestions?

Steps to reproduce

  1. run
image: docker:latest

services:
  - docker:dind

variables:
  API_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME

before_script:
  - apk add --no-cache py-pip
  - pip install docker-compose

stages:
  - test
  - auto-bump

test:
  stage: test
  script:
    - docker-compose run -e DJANGO_ENVIRONMENT=dev your_project python manage.py test # run tests

auto-bump:
  stage: auto-bump
  image: python:3.6
  before_script:
    - "which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )"
    - eval `ssh-agent -s`
    - echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null # add ssh key
    - pip3 install -U Commitizen # install commitizen
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_PUBLIC_KEY" >> ~/.ssh/id_rsa.pub
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  dependencies:
    - test
  script:
    - git remote set-url origin git@gitlab.com:discover/rentee-core.git # git configuration
    - git config --global user.email "${CI_EMAIL}" && git config --global user.name "${CI_USERNAME}"
    - 'exists=`git show-ref refs/heads/master` && if [ -n "$exists" ]; then git branch -D master; fi'
    - git checkout -b master
    - cz bump # execute auto bump and push to master
    - git push origin master:$CI_COMMIT_REF_NAME
    - TAG=$(head -n 1 VERSION) # get the new software version and save into artifacts
    - echo "#!/bin/sh" >> variables
    - echo "export TAG='$TAG'" >> variables
    - git push origin $TAG
  only:
    refs:
      - master
  artifacts:
    paths:
      - variables

on a gitlab runner

Current behavior

I don't necessarily think this is a bug and maybe this goes somewhere else? If someone could let me know I can def move it!

Desired behavior

cz bump works in ci/cd pipeline

Screenshots

No response

Environment

Commitizen Version: 2.35.0
Python Version: 3.9.13 (main, Aug 25 2022, 23:26:10)
[GCC 11.2.0]
Operating System: Linux

Python 3.8

Activity

woile

woile commented on Oct 19, 2022

@woile
Member

This example is out of date, so it definitely needs a proper review. But looking at your error, it looks like you could change the bump with cz bump --yes. This will answer the questions raised with the first time you bump.

courtneysprouse

courtneysprouse commented on Oct 19, 2022

@courtneysprouse
Author

Ah yes! That works thank you!

added a commit that references this issue on Apr 28, 2023
fbd2e21
added a commit that references this issue on May 2, 2023
2bd2547
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @woile@Lee-W@courtneysprouse

        Issue actions

          Issues Running cz bump in ci/cd pipeline · Issue #610 · commitizen-tools/commitizen