Synopsis

mod-connect jenkins [--createValidateJobs] [--deleteSkipped] [--downloadCLI] [--skipSSL] [--verbose] [--workspaceCleanup] [--agent=<agent>] [--cliVersion=<cliVersion>] [--commandSuffix=<commandSuffix>] --controllerUrl=<controllerUrl> [--defaultBranch=<defaultBranch>] [--downloadCLICreds=<downloadCLICreds>] [--downloadCLIUrl=<downloadCLIUrl>] [--folder=<folder>] --fromCsv=<fromCsv> --gitCredsId=<gitCredsId> --jenkinsUser=<jenkinsUser> [--mavenSettingsConfigFileId=<mavenSettingsConfigFileId>] [--platform=<platform>] [--prefix=<prefix>] --publishCredsId=<publishCredsId> --publishUrl=<publishUrl> [--scheduledAt=<scheduledAt>] [--credentials=<String=String>]…​ (--apiToken=<apiToken> | --jenkinsPwd=<jenkinsPwd>) [--moderneUrl=<moderneUrl> --moderneToken=<moderneToken>]

Description

Creates a Jenkins Job for each configured repository that will build and publish LST artifacts to your artifact repository on a regular basis.

Example:

mod connect jenkins --apiToken jenkinsApiToken \
   --controllerUrl https://jenkins.company-name.com \
   --fromCsv /path/to/repos.csv \
   --gitCredsId username-pat \
   --jenkinsUser some-username \
   --publishCredsId artifactory \
   --publishUrl https://artifact-place.com/artifactory/moderne-ingest

Options

--agent=<agent>

An expression to match the Jenkins agent that will run the job.

--apiToken=<apiToken>

The Jenkins apiToken that will be used when authentication is needed in Jenkins (e.g., the creation of Jenkins Jobs).

--cliVersion=<cliVersion>

The version of the Moderne CLI that should be used when running Jenkins Jobs.

--commandSuffix=<commandSuffix>

The suffix that should be appended to the Moderne CLI command when running Jenkins Jobs.

Example: --dry-run

--controllerUrl=<controllerUrl>

The URL of the Jenkins controller that will create the jobs. Typically this is the URL of your Jenkins instance.

--createValidateJobs

(Incubating) If supplied validate jobs will be created for each repository.

--credentials=<String=String>

Extra credentials to bind in the form of CRENDENTIALS_ID=VARIABLE for StringBinding or CREDENTIALS_ID=USERNAME_VARIABLE:PASSWORD_VARIABLE for UsernamePasswordMultiBinding

--defaultBranch=<defaultBranch>

If no Git branch is specified for a repository in the CSV file, the Jenkins Job will attempt to checkout this branch when pulling down the code.

Default: main

--deleteSkipped

If set to true, whenever a repository in the CSV file has 'skip' set to true, the corresponding Jenkins Job will be deleted. This is useful if you want to remove specific jobs that are failing, but you also want to preserve the list of repositories that are ingested.

Default: false

--downloadCLI

Specifies whether or not the Moderne CLI should be downloaded at the beginning of each Jenkins Job run.

Default: false

--downloadCLICreds=<downloadCLICreds>

Specifies the Jenkins credentials Id to download the CLI if you host the CLI yourself.

--downloadCLIUrl=<downloadCLIUrl>

Specifies an internal URL to download the CLI from if you’d prefer to host the CLI yourself.

--folder=<folder>

The Jenkins folder that will store the created jobs. This folder will be created if it does not exist.

Default: moderne-ingest

--fromCsv=<fromCsv>

The location of the CSV file containing the list of repositories that should be ingested. One Jenkins Job will be made for each repository. Follows the schema of:

[scmHost,repoName,repoBranch,mavenTool,gradleTool,jdkTool,desiredStyle,additionalBuildArgs,skip,skipReason]

  • scmHost: Optional - The URL of the source code management tool where the repository is hosted.

    • Example: github.com or gitlab.com

  • repoName: Required - The repository that should be ingested. Follows the format of: organization/repository.

    • Example: openrewrite/rewrite

  • repoBranch: Optional - The branch of the above repository that should be ingested.

    • Default: main

  • mavenTool: Optional - The name of the Maven tool that should be used to run Maven jobs. Specified in the Jenkins Global Tool Configuration page:

    {controllerUrl}/manage/configureTools/
  • gradleTool: Optional - The name of the Gradle tool that should be used to run Gradle jobs. Specified in the Jenkins Global Tool Configuration page:

    {controllerUrl}/manage/configureTools/
  • jdkTool: Optional - No longer in use.

  • desiredStyle: Optional - The OpenRewrite style name to apply during ingest.

    • Example: org.openrewrite.java.SpringFormat

  • additionalBuildArgs: Optional - Additional arguments that are added to the Maven or Gradle build command.

    • Example: -Dmaven.antrun.skip=true

  • skip: Optional - If set to true, this repo will not be ingested.

    • Default: false

  • skipReason: Optional - The context for why the repo is being skipped.

    CSV Example:

    ,openrewrite/rewrite-spring,main,,gradle,,,,,
    ,openrewrite/rewrite-java-migration,main,,gradle,,,,,
    additional rows...
--gitCredsId=<gitCredsId>

The ID of the Jenkins credentials needed to clone the provided list of repositories.

--jenkinsPwd=<jenkinsPwd>

The Jenkins password that will be used when authentication is needed in Jenkins (e.g., the creation of Jenkins Jobs).

Jenkins best practices recommend using an apiToken instead of a password.

--jenkinsUser=<jenkinsUser>

The Jenkins user that will be used to create the Jenkins Jobs.

--mavenSettingsConfigFileId=<mavenSettingsConfigFileId>

The ID of the Jenkins Maven settings config file that will be used to configure Maven builds. Specified in the Jenkins Global Tool Configuration page:

{controllerUrl}/manage/configureTools/
--moderneToken=<moderneToken>

A personal access token for the Moderne tenant.

--moderneUrl=<moderneUrl>

The URL of the Moderne tenant.

--platform=<platform>

The OS platform for the Jenkins node/agent. The possible options are: windows, linux, or macos.

Default: linux

--prefix=<prefix>

If specified, Jenkins Jobs will only be created for repositories that start with this prefix.

--publishCredsId=<publishCredsId>

The ID of the Jenkins credentials needed to upload LST artifacts to your artifact repository.

--publishUrl=<publishUrl>

The URL of the Maven repository where LST artifacts should be uploaded to.

Will default to the environment variable MODERNE_PUBLISH_URL if one exists.

--scheduledAt=<scheduledAt>

The cron schedule that the Jenkins Jobs should follow. By default, Jenkins will execute each job once a day while making sure to space them out so that the system is not overloaded at one particular time.

Default: H H * * *

--skipSSL

If this parameter is included, SSL verification will be skipped on the generated jobs.

Default: false

--verbose

If enabled, additional debug statements will be printed throughout the Jenkins configuration.

Default: false

--workspaceCleanup

If enabled, use the WsCleanup plugin to clean the workspace after finishing the job.

Default: false

Notes:

If you are a CloudBees CI authenticated user, you will also need these permissions:

  1. Overall/System Read access. This is needed to get the list of plugins and their versions.

    • GET /pluginManager/api/json

  2. Create, Configure, Read folders and Jobs.

    • POST /createItem

    • GET /job/$folder/api/json

    • GET /job/$folder/job/$item/api/json

  3. (Optionally) Delete jobs. This is only required if --deleteSkipped is selected.

    • POST /job/$folder/job/$item/doDelete

For more details around these permissions, please see: https://cutt.ly/75J0mtI