Giter VIP home page Giter VIP logo

azure-iot-edge-jenkins-plugin's Introduction

Azure IoT Edge Plugin

Azure IoT Edge Plugin makes it easy to setup a CI/CD pipeline for developing an IoT Edge solution on Jenkins, by providing following functionalities:

  • Continuous integration(build and push docker image)
  • Continuous deployment(create Edge deployment on Azure)

Feedback

  • If you encounter any bugs with this plugin please file an issue in Jenkins JIRA under component azure-iot-edge-plugin.

  • You can also contact this Email group for issues [email protected]

Overview

This is the work flow for Azure IoT Edge solution CI/CD pipeline. Structure

How to Install

Prerequisites

Install following tools on Jenkins host.

Install extension

You can install/update this plugin in Jenkins update center (Manage Jenkins -> Manage Plugins, search Azure IoT Edge Plugin).

You can also manually install the plugin if you want to try the latest feature before it's officially released. To manually install the plugin:

  1. Clone the repo and build. (The integration test need about 30 minutes to run, you can skip by following command):
    mvn package -Dmaven.test.skip=true
    
  2. Open your Jenkins dashboard, go to Manage Jenkins -> Manage Plugins.
  3. Go to Advanced tab, under Upload Plugin section, click Choose File.
  4. Select azure-iot-edge.hpi in target folder of your repo, click Upload.
  5. Restart your Jenkins instance after install is completed.

Before using extension

To use this plugin to build and deploy Azure IoT Edge solution, first you need to have an Azure Service Principal in your Jenkins instance.

  1. Create an Azure Service Principal through Azure CLI or Azure portal. Make sure in order to use Service Principal for CI/CD, you need to create the role at least Contributor. Otherwise it doesn't have enough permission to create deployment on IoT Hub.
  2. Open Jenkins dashboard, go to Credentials, add a new Microsoft Azure Service Principal with the credential information you just created.
  3. If you use common docker registry credential(like docker hub), you may also add a new Username with password credential.
  4. Existing Azure IoT Hub and docker registry are needed in CI/CD.

Create a project

In Jenkins, there are two types of project.

  • Freestyle project: Config through UI
  • Pipeline project: Config through code

Create a Freestyle project

Build and Push task

Build

  1. In Build section, click Add build step, then choose Azure IoT Edge Build and Push.
  2. Set Solution Root Path, in most cases it's where deployment.template.json located.
  3. Set Bypass modules, it is the list of modules to bypass when building, use comma delimited list of modules. Example "ModuleA,ModuleB". You can leave this field empty to build all modules.
  4. Choose docker registry in Docker Credential Configuration.
  • For Azure Container Registry, you need to use the Azure Service Principal created above to authenticate.
  • For other types of registry(docker hub), you need to specify Docker registry URL and then a credential with type Username with password.

Deploy task

Deploy

  1. In Build section, click Add build step, then choose Azure IoT Edge Deploy.
  2. Set Solution Root Path, in most cases it's where deployment.template.json located.
  3. Choose Azure IoT Hub.
  4. Set deployment configurations. You can click help button after the input box to get detailed explanation of the item.

Create a Pipeline project

You can also use this plugin in pipeline (Jenkinsfile). Here are some samples to use the plugin in pipeline script, there is also an example for pipeline project.

Project config on Jenkins

pipeline

Customize pipeline: Build and Push task

Use Azure Container Registry
azureIoTEdgePush dockerRegistryType: 'acr', acrName: '<acr_name>', bypassModules: '', azureCredentialsId: '<azure_credential_id>', resourceGroup: '<resource_group_name>', rootPath: '<solution_root_path>'
Use common Container Registry
azureIoTEdgePush dockerRegistryType: 'common', dockerRegistryEndpoint: [credentialsId: '<credential_id>', url: '<url>'], bypassModules: '', resourceGroup: '<resource_group_name>', rootPath: '<solution_root_path>'

Customize pipeline: Deploy task

For single device
azureIoTEdgeDeploy azureCredentialsId: '<azure_credential_id>', deploymentId: '<deployment_id>', deploymentType: 'single', deviceId: '<device_id>', iothubName: '<iothub_name>', priority: '<priority>', resourceGroup: '<resource_group_name>', rootPath: '<solution_root_path>', targetCondition: ''
For multiple devices using target condition
azureIoTEdgeDeploy azureCredentialsId: '<azure_credential_id>', deploymentId: '<deployment_id>', deploymentType: 'multiple', targetCondition: '<target_condition>', iothubName: '<iothub_name>', priority: '<priority>', resourceGroup: '<resource_group_name>', rootPath: '<solution_root_path>', targetCondition: ''

For advanced options, you can use Jenkins Pipeline Syntax tool to generate a sample script.

FAQ

Does ARM platform supported?

If you would like to build ARM platform image, you'll need to setup an ARM build agent. And for the Prerequisites, they also need to be setup on build agent.

Data/Telemetry

Azure IoT Edge Plugin for Jenkins collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more.
You can turn off usage data collection in Manage Jenkins -> Configure System -> Azure -> Help make Azure Jenkins plugins better by sending anonymous usage statistics to Azure Application Insights.

azure-iot-edge-jenkins-plugin's People

Contributors

michaeljqzq avatar microsoft-github-policy-service[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-iot-edge-jenkins-plugin's Issues

Build step 'Azure IoT Edge Deploy' marked build as failure

http://10.172.14.160:8080/job/liunx-mm/2/console

ERROR: Build step failed with exception
java.lang.NullPointerException
at com.microsoft.jenkins.iotedge.EdgeDeployBuilder.perform(EdgeDeployBuilder.java:200)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1816)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Build step 'Azure IoT Edge Deploy' marked build as failure
Finished: FAILURE

java.lang.NullPointerException when choose Resource Group Name or IoT Hub Name

when user choose Resource Group Name or IoT Hub Name some times, bellow error will pop up

step:

  1. New Item and create Freestyle project
  2. add build step ---Azure IoT edge deploy
    3.select Azure Credentials , Resource Group Name and IoT Hub name
  3. select Deploy to single device
    here it work well.
  4. select another Resource Group Name again
    here you can see the error in "Deploy to single device " Filed
    image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.