opendevstack / ods-jenkinsfile-converter

Convert a Jenkinsfile from ODS 3.x to 4.x

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ods-jenkinsfile-converter

build

Introduction

This is a Golang CLI to convert the a Jenkinsfile based on 3.x to 4.x based on the official required changes.

Download

Target a specific version and platform for the binary. For version v0.1.2 and linux, you would:

  curl -L https://github.com/opendevstack/ods-jenkinsfile-converter/releases/download/v0.1.2/converter -o converter
  sudo mv converter /usr/local/bin

For other platforms like Windows or MacOS choose the binary from the links here.

Usage

Given a Jenkinsfile based on 3.x, to preview the changes that will result when migrating to ODS 4.x, use the --dry-run flag

  converter -filename="examples/machine-learning/Jenkinsfile" --dry-run

or to persist the changes in an output file

  converter -filename="examples/machine-learning/Jenkinsfile" -out "out/Jenkinsfile"

The converted Jenkinsfile with the ODS 4.x adopted changes will be under the out directory:

  cat out/Jenkinsfile

Building it locally

Generate the binaries under bin

  make all

You can run the binary for your platform. To preview the changes that will be done, use the --dry-run flag

  ./bin/converter -filename="examples/machine-learning/Jenkinsfile" --dry-run

Run it with Go

  go run . -filename="examples/machine-learning/Jenkinsfile" -out "out/Jenkinsfile"

Features

This tool will carry out the following changes in an ODS 3.x Jenkinsfile:

  • Update @Library('ods-jenkins-shared-library@3.x') _ to @Library('ods-jenkins-shared-library@4.x') _

  • Point to agent images with the 4.x tag, e.g. change imageStreamTag: ods/jenkins-agent-golang:3.x to imageStreamTag: ods/jenkins-agent-golang:4.x.

  • NodeJS agent name is going to change in ODS 4. From jenkins-agent-nodejs10-angular to jenkins-agent-nodejs12.

  • odsComponentStageImportOpenShiftImageOrElse has been deprecated, and is now aliased to the new method, odsComponentFindOpenShiftImageOrElse.

  • odsComponentStageRolloutOpenShiftDeployment rolls out all deployment resources together now. If you had multiple DeploymentConfig resources previously, you had to target each one by specifying the config option resourceName. This is no longer possible - instead the stage iterates over all DeploymentConfig resources with the component label (app=${projectId}-${componentId}). Changes must be made to pipelines that have multiple deployments, such as components based on the ds-jupyter-notebook and ds-rshiny quickstarter.

    For instance, the following must be changed from:

    odsComponentStageRolloutOpenShiftDeployment(context, [resourceName: "${context.componentId}-auth-proxy"])

    to:

    odsComponentStageRolloutOpenShiftDeployment(context)

Limitations

  • Only Jenkinsfiles from 3.x are supported.

About

Convert a Jenkinsfile from ODS 3.x to 4.x


Languages

Language:Go 90.4%Language:Makefile 9.6%