Azure Pipelines

Native plugin directly available in the Marketplace

Setup

You can get the plugin directly from the Visual Studio Marketplace.

Prerequisites

manifest.yml file

Place the manifest.yml file containing the correct information about your project in your project repository. You can use any path you want, this is passed to the LeanIX pipeline task as an input parameter.

miCiCd-init.gradle

If you are using Gradle as a dependency manager on your project, you need to use the contents of the file mentioned below, in the root of your repository with the name 'miCiCd-init.gradle'.

initscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }

    dependencies {
        classpath 'com.github.jk1:gradle-license-report:1.16'
    }
}

import com.github.jk1.license.render.*

allprojects {
    rootProject.allprojects {
        apply plugin: 'java'
        apply plugin: 'maven-publish'
        apply plugin: com.github.jk1.license.LicenseReportPlugin
        licenseReport {
            // Set custom report renderer, implementing ReportRenderer.
            // Yes, you can write your own to support any format necessary.
            renderers = [new JsonReportRenderer('licenses.json')]
        }
                publishing {
            publications {
                maven(MavenPublication) {
                    groupId = 'org.gradle.sample'
                    artifactId = 'library'
                    version = '1.1'

                    from components.java
                }
            }
        }
    }
}

Secret LeanIX API token

In the “Edit”-section of your pipeline in which the LeanIX task is used, a secret must be created, the value of which is a valid LeanIX token for the host that is used in the task.

For the use of secrets in Azure DevOps pipelines see also Define variables - Azure Pipelines

Configuration

Adding the task to your Azure DevOps pipeline

If you want to add the LeanIX task to an Azure DevOps pipeline, you can either use the example pipeline code listed below or use the search field for tasks in the edit mode of your Azure DevOps pipeline. For more information on how to use tasks, see also Key concepts for new Azure Pipelines users and the related pages.

In the search field search for “LeanIX” and click on the upcoming result task. In the appearing input dialog for the task specify the input parameters according to the description of the parameters below on this page. Of course you can also use environment variables as input parameters here ( Define variables - Azure Pipelines ).

Monitoring of pipeline runs

The monitoring of the pipeline including the LeanIx task can be done in the runs overview belonging to the pipeline or for continuous monitoring you can see also Add continuous monitoring to your release pipeline- Azure Monitor .

Simple example pipeline with the LeanIX DevOps task

The input parameters used in the example are explained in more detail in the "Inputs" section.

📘

In the example below, the API token to access the LeanIX API is read from the secret variable $(apitoken) (see also Secret LeanIX API token).

trigger:
    - main
    
    pool:
      vmImage: ubuntu-latest
      
    steps:
    
    - task: [email protected]
      inputs:
        apitoken: '$(apitoken)'
        host: 'app.leanix.net'
        manifestpath: '/lx-manifest.yml'
        stage: 'test'
        version: '1.2.4'
        dependencymanager: 'NPM'
        allowfailure: true

Mandatory and optional definitions

The steps and assignments carried out in the example are necessary for the use of the LeanIX task. In addition to the input parameters of the task under “inputs:” to be set correctly, you can choose the following values ​​yourself:

  • “-task: [email protected]": By changing the version of the task after “@” you can choose which version of the LeanIX task you want to use, if more than one is available in the Visual Studio Marketplace.

Inputs

attribute

description

required

host

The LeanIX host where the connector is located that should be used by the action, e.g.: eu.leanix.net

yes

api-token

The LeanIX API token for secure access to the LeanIX connector API on the chosen host. Use the name you chose for the secret in the project settings here.

yes

manifest-path

The path to the LeanIX manifest in your repository. Default: /lx-manifest.yml

yes

dependency-manager

Type of the dependency manager used for the project. Supported possible values: NPM, MAVEN, GRADLE, NUGET.

yes

stage

The stage the workflow is triggered for. Default: production

no

version

The current version the workflow is triggered for.

yes

allow-failure

Flag that indicates whether the entire workflow is allowed to continue if an error occurs in the LeanIX action. "True" means, the workflow continues upon error in the action, "false" makes it exit with error. Default: true

no

📘

Handling dependencies from private repositories or registries

The plugin always captures dependencies from both public-facing and private (Internal) repositories. In order to capture dependencies from private repositories, you must ensure the correct ordering of the tasks in Azure build pipeline where the authentication task (for respective private repositories) must precede the Leanix plugin task.

In a scenario where the dependencies declared in a private repository are not accessible, the plugin captures at least the dependencies that are public-facing for Gradle, Maven, and NPM dependency managers. To avail of this feature, you have to ensure the following for respective dependency managers.

  • For Gradle, ensure you have updated miCiCd-init.gradle file.
  • For NPM, ensure LeanIX-Microservice-Intelligence task is placed after the 'npm install' task in your azure build pipeline.

Note: This feature is not supported for other dependency managers like NUGET (Coming Soon!)

Options

Support for Custom Gradle Version

In a scenario where your repo has a strong dependency to build with a particular Gradle version, the plugin also needs the Gradle wrapper (with the custom Gradle version) used for the build.

The version of Gradle installed on the Azure build agent machine will be used by default unless:

  • your repo has gradlew executable file on its root folder or
  • your repo's gradle/wrapper/gradle-wrapper.properties file has a distributionUrl property that specifies a different Gradle version to download and use during the build.
12491249

Did this page help you?