Yes, this is pretty easy with Jenkinsfiles with no need for any third-party plugins or anything along those lines: use the built-in Pipeline build step.
I use this to trigger builds of projects in a dependency chain, so that after one project builds successfully, other projects that depend on it will pull in the updated dependency and build against it.
Here is what this looks like in a Jenkinsfile:
build repoName
where repoName
is a variable containing the name of the repository you wish to build.
Things can get a little more complicated, such as if you're using folders or Multibranch Pipelines:
build "${projectName}/${repoName}/${branchName}"
This example builds a job within a Multibranch project where the variables are:
projectName
- the name of my Multibranch project
repoName
- the name of the repository
branchName
- the name of the branch to build, usually master
Or this example builds a job with parameters and also triggers the build asynchronously (parent job won't wait for child job to complete before moving on to the next step):
build(
jobName,
wait: false,
parameters: [
[
$class: 'BooleanParameterValue',
name: 'someBooleanParameter',
value: true,
],
[
$class: 'StringParameterValue',
name: 'someStringParameter',
value: 'some string value',
],
],
)
As you can see, the invocation of build
can get relatively complex. See the documentation linked above for more complete information.