Sidorov Andrew
Sidorov Andrew

Reputation: 11

Build many dockerfiles on jenkins project

I have some task:

I have github repostiroy with folder "docker" and in this folder have many sub-folders with names (app1, app2, app3, etc.) with only Dockerfile in subfolder.

Sometimes i add new subfolder with name app50 and i want to Jenkins build automatically this new dockerfile and if all ok push new images to private docker registry.

How I can automate to select sub-folder, enter to him and run docker build ? with cutsom tag and name.

For example i upload new folder "app70-1.2.3" with Dockerfile. Jenkins need enter to folder "docker/app70-1.2.3" and run "docker build -t app70:1.2.3 ."

Upvotes: 1

Views: 470

Answers (1)

ekostadinov
ekostadinov

Reputation: 6950

I am using similar approach and the simplest way to achieve this in your case could be via Feature branching strategy. Just use your branch as folder name and then run something like this as Jenkins (shell) build step:

cd ${GIT_BRANCH}
docker build -t ${GIT_BRANCH} .

Upvotes: 1

Related Questions