Skip to content

feat: use docker entrypoint #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2023
Merged

Conversation

evantill
Copy link
Contributor

fixes issue #12

BREAKING CHANGE: wrapping script are simplified but not compatible with previous version

@evantill
Copy link
Contributor Author

evantill commented Apr 16, 2023

Hi, any update on this PR please ? You can close it if you are not interested by merging it

@woile
Copy link
Member

woile commented Apr 16, 2023

I think we can merge it, could you add a migration guide to the commit message? thanks!

@evantill
Copy link
Contributor Author

I have updated the usage examples in the README.md accordingly

@evantill
Copy link
Contributor Author

@woile
Copy link
Member

woile commented Apr 18, 2023

I don't think that's enough, because that's how to use it now.

This change will probably break some people's code, I'd like them to come to the README to see what happened, and see a solution right away, a "miration guide", where they realize they only need to chnage a few things to mitigate the impact.

I think something as simple as:

## Migration guide

We've moved this images from using `CMD` to `ENTRYPOINT`.

Where you were doing this:

docker run --rm --name commitizen registry.hub.docker.com/commitizen/commitizen:2 /bin/sh -c "cz ls"

Now you only need to do:

docker run --rm --name commitizen registry.hub.docker.com/commitizen/commitizen:2 ls

What do you think?

@woile
Copy link
Member

woile commented Apr 19, 2023

While reviewing the docs, I noticed that for Jenkins we run the command inside a docker image:

useCz {
   sh "cz bump --changelog"
}

The useCz internally uses this docker image. Now, this is good, because teams can put the cz bump inside a Makefile, and they can still do:

useCz {
   sh "make bump"
}

Which has the benefit of working also locally.

How would people achieve the same with this PR?

@evantill
Copy link
Contributor Author

Not sure to understand the question.

useCz {
   sh "cz bump --changelog"
}

use the method

def useCz(String authorName = 'Jenkins CI Server', String authorEmail = 'your-jenkins@email.com', String image =  'registry.hub.docker.com/commitizen/commitizen:latest', Closure body) {
    docker
    .image(image)
    .inside("-u 0 -v $WORKSPACE:/workspace -w /workspace -e GIT_AUTHOR_NAME='${authorName}' -e GIT_AUTHOR_EMAIL='${authorEmail}'") {
        sh "git config --global user.email '${authorName}'"
        sh "git config --global user.name '${authorEmail}'"
        body()
    }
}

so this is equivalent to

  docker
    .image(image)
    .inside("-u 0 -v $WORKSPACE:/workspace -w /workspace -e GIT_AUTHOR_NAME='${authorName}' -e GIT_AUTHOR_EMAIL='${authorEmail}'") {
        sh "git config --global user.email '${authorName}'"
        sh "git config --global user.name '${authorEmail}'"
        sh "cz bump --changelog"

@evantill
Copy link
Contributor Author

As explained in the updated readme, we can override the entrypoint using --entrypoint /bin/sh. This could be the change needed in jenkins script.

docker run --rm -it \
  --entrypoint /bin/sh \
  -v $(pwd):/app \
  commitizen/commitizen:latest

@evantill
Copy link
Contributor Author

evantill commented Apr 19, 2023

see https://issues.jenkins.io/browse/JENKINS-51307 for passing the entrypoint in the docker pipeline:

customImage.inside("-u root --entrypoint='/start.sh'") {}

in this case the update should be (see the end of the line .inside())

def useCz(String authorName = 'Jenkins CI Server', String authorEmail = 'your-jenkins@email.com', String image =  'registry.hub.docker.com/commitizen/commitizen:latest', Closure body) {
    docker
    .image(image)
    .inside("-u 0 -v $WORKSPACE:/workspace -w /workspace -e GIT_AUTHOR_NAME='${authorName}' -e GIT_AUTHOR_EMAIL='${authorEmail}' -entrypoint='/bin/sh'") {
        sh "git config --global user.email '${authorName}'"
        sh "git config --global user.name '${authorEmail}'"
        body()
    }
}

@woile
Copy link
Member

woile commented Apr 21, 2023

Thanks. I'll merge it soon.

This breaking change will be part of commitizen v3 release.

@woile
Copy link
Member

woile commented Apr 23, 2023

Could you please rebase? Thanks!

fixes issue commitizen-tools#12

BREAKING CHANGE: wrapping  script are simplified but not compatible with previous version
@evantill
Copy link
Contributor Author

evantill commented May 1, 2023

done

@woile woile merged commit 74a1758 into commitizen-tools:master May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants