chacham15
chacham15

Reputation: 14281

How do I chain Jenkins pipelines from a checked out git repo?

I want to checkout a git repo and then run its build so I tried:

sh "git clone --depth 1 -b master [email protected]:user/repo.git"
build './repo'

but that yields:

ERROR: No item named ./repo found

I've tried to use dir('repo') but apparently that errors when you run it from within docker (because kubernetes is stuck on an old version of docker that doesnt support this).

Any idea on how to run the build pipeline from the checked out repo?

Upvotes: 3

Views: 1523

Answers (1)

yorammi
yorammi

Reputation: 6458

The 'build' pipeline steps expect a job name, not a pipeline folder with a Jenkinsfile in its root folder.

The correct way to do this is to set the pipeline job with the Jenkinsfile, as described here ('In SCM' section), and call it by its Job name from your pipeline.

Pipelines are not built for chaining unless you use shared libraries where you put the Pipeline code in a Groovy class or as a step, but that it is a subject for a full article.

Upvotes: 5

Related Questions