Jenkins plugin for the upcoming version 2 of SCM-Manager.
Integrate your repositories from different SCM with this plugin!
Note: This plugin requires SCM-Manager in order to be useful. Feel free to check it out in case you haven't been used to it yet.
Download/Install latest SCM-Manager version »For full functionality, this plugin requires SCM-Manager v3 (see above) with an installed
Jenkins plugin for the triggers and the
CI plugin to show the build results inside SCM-Manager. To create
SSH connection between Jenkins and SCM-Manager, you can use the
SSH plugin.
This plugin gives various ways to connect your SCM-Manager with Jenkins, like sending build status, multibranch
pipelines, folders for complete namespaces, and navigation items.
Once the plugin is installed, it will automatically detect whether any jobs have configured an scm pointing to an instance of an SCM-Manager.
If such a build job starts, the plugin will send the PENDING
state for the checkout revision to SCM-Manager.
After the build is complete, the plugin will send the resulting state to SCM-Manager (SUCCESS
, UNSTABLE
or FAILURE
).
For multibranch pipelines, there is a new branch source named “SCM-Manager”.
You can create pipelines in Jenkins that can find branches, tags, and pull requests in SCM-Manager hosted repositories on their own.
In cooperation with the Jenkins plugin in SCM-Manager, the Jenkins CI server will receive hooks on every change and trigger new builds.
To remove stale jobs like for no longer available repositories, you can manually execute “Scan Namespace Now”.
To create such a pipeline, select “New Item” on the Jenkins top level page, then enter a name and select “Multibranch
Pipeline”.
In the configuration form for this item, select the matching “SCM-Manager” entry for your repository type in the “Add
source” dropdown in the section “Branch Sources”.
In the new configuration, enter the base URL of your SCM-Manager instance and select according credentials.
This plugin will then load a list of all available repositories you can select from.
You may also copy and paste a repository into the field.
Finally, you can select behaviours where you can choose whether branches, tags or pull requests shall be built (among others).
In order to create an SCM-Manager Mercurial or Git repository with the Jenkins JobDSL, the following syntax can be used:
multibranchPipelineJob('heart-of-gold') {
branchSources {
scmManager {
id('spaceships/heart-of-gold')
serverUrl('https://scm.hitchhiker.com')
credentialsId('my-secret-id')
repository('spaceships/heart-of-gold')
discoverBranches(true)
discoverPullRequest(true)
discoverTags(false)
}
}
}
The parameters discoverBranches
, discoverPullRequest
and discoverTags
are optional
and describe which heads of the repository are build.
The example shows the default values.
Have a look at the following example for a Subversion repository:
multibranchPipelineJob('heart-of-gold') {
branchSources {
scmManagerSvn {
id('spaceships/heart-of-gold')
serverUrl('https://scm.hitchhiker.com')
credentialsId('my-secret-id')
repository('spaceships/heart-of-gold')
includes("trunk,branches/*,tags/*,sandbox/*")
excludes("")
}
}
}
If you want to have build jobs for every repository in a namespace, you can create “SCM-Manager Namespace” jobs. These
will scan all repositories in the given namespace and create multibranch pipelines for each repository where a
Jenkinsfile
can be found. If a new repository is created in this namespace, a new pipeline will be created
automatically.
To create such a folder for a complete namespace, select “New Item” on the Jenkins top level page, then enter a name
and select “Organization Folder”.
In the configuration form for this item, select the Repository Sources > Add button and choose SCM-Manager Namespace.
Within the new form, enter the base URL of your SCM-Manager instance and select according
credentials. This plugin will then load a list of all available namespaces you can select from.
As an alternative to a concrete namespace, you can select –all–
if you want to create build jobs for
all repositories of the whole SCM-Manager instance. Please note that in this case, the folders for the jobs will be
named with the pattern namespace/name.
Finally, you can select behaviours where you can choose whether (for example) branches, tags or pull requests shall be
built.
Have a look at the following example in order to create a build job for an SCM-Manager namespace with the JobDSL:
organizationFolder("spaceships") {
organizations {
scmManagerNamespace {
serverUrl('https://scm.hitchhiker.com')
credentialsId('my-secret-id')
namespace("spaceships")
discoverBranches(true)
discoverPullRequest(true)
discoverTags(false)
discoverSvn {
includes("trunk,branches/*,tags/*,sandbox/*")
excludes("")
}
}
}
}
// scan namespace directly after creation
queue("spaceships")
The discover*
parameters are optional, the example above shows the default values.
To disable subversion builds, a false
can be passed to the discoverSvn
method e.g.: discoverSvn(false)
.
To build all namespaces of the SCM-Manager instance, the pseudo namespace --all--
can be used.
In different pages of Jenkins, you can find links to the corresponding SCM-Manager page:
To build the plugin just run the maven package phase.
mvn package
Start the local Jenkins instance:
mvn hpi:run
At times, it may become necessary to update the Jenkins version of this
plugin. Take following steps into account: