0

I have Jenkins in a docker container and inside the container I have a local git repository, I added a post-commit file which runs a build in Jenkins each time a commit is made but the file doesn't run, what is the problem?

this is the post commit file (it's in the container)

Jenkins which is running inside the docker container on localhost

1 Answer 1

1

I see this mistake over and over again.

localhost is always resolved to the 127.0.0.1 of whatever machine it's used on. In context of the container 127.0.0.1 is the container itself, not the machine Docker is running on.

If both Jenkins and Git container use the same network, you can use Jenkins's container IP in your hook URL. Otherwise you need to put them on the same network first - see this question on how to do that.

Sign up to request clarification or add additional context in comments.

9 Comments

the file itself is not executing, when i execute git commit on the local git directory (which is inside the jenkins container ) the echo commands are not executed
So the post-commit hook is inside Git container and the commit is made from within Jenkins container? Then why would you assume it would work? Post-commit hook is a client-side hook (see git-scm.com/book/en/v2/Customizing-Git-Git-Hooks for details). Jenkins would need to create it by itself before commiting anything.
i don't have a git container i only have a jenkins container and i cloned the repository inside it
Are you executing the commit manually or from Jenkins job? Also where is the post-commit script located and what is it's filename?
i'm executing the commit manually in the local repository inside jenkins docker. the post-commit file is in .git/hooks its name is post-commit
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.