Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Steps to configure 3.0 Scripts in Automatics

Before configuring scripts, ensure that device models are mapped against corresponding device category in Automatics Orchestration.

  1. Execute Jenkins Job for Porting 3.0 APIs in Automatics Core project
  2. Execute Jenkins Job for Porting 3.0 APIs in Automatics Scriptless Automation project
  3. Execute Jenkins Job for Porting 3.0 APIs in RDKV Test Utils
  4. Execute Jenkins Job for Porting 3.0 APIs in RDKB Test Utils
  5. Import the json file for Test Utility from <Release page> via Automatics Orchestration
  6. Import the json file for Test Scripts from <Release page> via Automatics Orchestration
  7. Import the test script details in excel sheet in 1.0 format via Automatics Orchestration

Please follow the below steps to deploy automatics core to Artifact repositories from Jenkins job

Introduction

Jenkins is used by Automatics for following activities. 

  • To perform test execution.
  • To deploy Automatics Core to maven artifact repository.

Jenkins Setup

Steps to be taken care during Jenkins configuration

  • Install Java 1.8

    • Refer following web page to get detailed steps to install Java 1.8 on Linux.

Automatics Orchestration Setup#JDK1.8

  • Install Jenkins

Follow below steps to install and configure Jenkins in Linux

    • Enable the Jenkins repository. To do that, import the GPG key using the following curl command.

"curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo"

Sample Output:

Image Removed

    • And add the repository to your system with:

"sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key"

...

"sudo yum install jenkins"

    • After the installation process is completed, start the Jenkins service with:

"systemctl start jenkins"

To check whether it started successfully run:

"systemctl status jenkins"

Sample Output:

Image Removed

    • Finally enable the Jenkins service to start on system boot.

"sudo systemctl enable jenkins"

  • Setting Up Jenkins

    • To set up your new Jenkins installation, open your browser and type your domain or IP address followed by port 8080:

"http://your_ip_or_domain:8080"

    • A screen similar to the following will appear, prompting you to enter the Administrator password that is created during the installation.

Image Removed

    • Use the following command to print the password on your terminal.

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

You should see a 32-character long alphanumeric password.

    • Copy the password from your terminal, paste it into the Administrator password field and click Continue.
    • On the next screen, you will be asked whether you want to install the suggested plugins or to select specific plugins. Click on the Install suggested plugins box, and the installation process will start immediately. 

Image Removed

Image Removed

    • Once the installation is complete, you will be prompted to set up the first administrative user. Fill out all required information and click Save and Continue.
    • On the next page, you will be asked to set the URL for the Jenkins instance. The URL field will be populated with an automatically generated URL.
    • To complete the setup confirm the URL by clicking on the Save and Finish button.
  • Follow below steps to Disable CSRF protection by setting system property 'hudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION' set to true. More details available at https://www.jenkins.io/doc/book/security/csrf-protection/ .

    • To disable CSRF it can be done with groovy  , Navigate to  "Manage Jenkins > Script Console " in Jenkins.
    • Enter the list of commands shown in the below screenshot and click on "Run".

Image Removed

  • Install Maven 3

Refer following webpage to setup Maven 3 on Linux.

Automatics Orchestration Setup#Maven3

Jenkins Job for Test Execution

Automatics performs test execution in Jenkins. Following page will provide details on creating Jenkins job for test execution.

Jenkins Job for Test Execution

Jenkins Job for Automatics Core Deployment

As part of Automatics setup, partner has to deploy automatics core in their own self hosted maven artifact repository. Automatics-core artifact to be deployed will be generated in format format 'automatics-core-{version}.jar'.

Following page will provide details on creating Jenkins job for Automatics Core deployment.

Automatics Core : Jenkins Deployment Job configuration

1.Creating Jenkins job

  • From Jenkins, select “New Item”,
    Image Removed
  • Specify name of the new job to be created.
  • Select ‘OK’ button.

2. Configuration of Jenkins Job

Configure General Settings

  • In ‘General’ settings, add proper description in the ‘Description’ section
  • Check ‘Discard old builds’ checkbox

Configure Source Code Management

  • In ‘Source Code Management’, select git and under ‘Repository’ add the repo detail

 eg : ‘https://code.rdkcentral.com/r/rdk/tools/automatics/automatics-core’ and also add the repo credentials

Image Removed

  • Also add the branch of the repository in ‘Branches to build’

    eg : */rdk-next

    Image Removed

Configure Build Triggers

  • In build triggers section select ‘Poll SCM’ and enter the schedule. By this configuration, there will be a polling to the repo for any changes periodically and if there are any changes then the Jenkins build will be executed

    Eg : @hourly means the job will check for any changes in the remote repo for every 1 hour and if there are any changes, then the build will run

    Image Removed

Configure Build Environment

  • In ‘Build Environment’, select ‘Delete workspace before build starts’
    Image Removed

Configure Build Settings

  • In the ‘Build’ settings, Click on ‘Add build step’ and Select ‘Invoke top-level Maven level targets’

           Image Removed

  • Add the following maven step in the text box
    clean deploy -DaltDeploymentRepository=<id>::default::<Artifact repository path>
    altDeploymentRepository – Specifies an alternative repository to which the project artifacts should be deployed
  • Click on Advanced button in ‘Invoke top-level Maven level targets’ and add following maven configuration. In the image shown below, maven settings.xml is place at /mnt/maven directory.  Update the settings.xml path based on its location in partner's VM.

           Image Removed

           Reference - https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html

Save the Configuration

  • Click on ‘Apply’ and ‘Save’

Jenkins Deployment Pipeline

Table of Contents

General Overview

what is Jenkins Pipeline?

...

In simple words, Jenkins Pipeline is a combination of plugins that support the integration and implementation of continuous delivery pipelines using Jenkins. A pipeline has an extensible automation server for creating simple or complex delivery pipelines "as code," via pipeline DSL (Domain-specific Language).

what is Jenkins File?

Jenkins pipelines can be defined using a text file called Jenkins File. You can implement pipeline as code using Jenkins File, and this can be defined by using a domain specific language (DSL). With Jenkins File, you can write the steps needed for running a Jenkins pipeline.

The benefits of using Jenkins File are:

  • You can create pipelines automatically for all branches and execute pull requests with just one JenkinsFile.
  • You can review your code on the pipeline
  • You can audit your Jenkins pipeline
  • This is the singular source for your pipeline and can be modified by multiple users.

Jenkins File can be defined by either Web UI or with a Jenkins File.

Declarative versus Scripted pipeline syntax:

There are two types of syntax used for defining your Jenkins File.

  1. Declarative
  2. Scripted

Declarative:

Declarative pipeline syntax offers an easy way to create pipelines. It contains a predefined hierarchy to create Jenkins pipelines. It gives you the ability to control all aspects of a pipeline execution in a simple, straight-forward manner.

Scripted:

Scripted Jenkins pipeline runs on the Jenkins master with the help of a lightweight executor. It uses very few resources to translate the pipeline into atomic commands. Both declarative and scripted syntax are different from each other and are defined totally differently.

why use Jenkins pipeline?

Jenkins is an open continuous integration server which has the ability to support the automation of software development processes. You can create multiple automation jobs with the help of use cases, and run them as a Jenkins pipeline.

Here are the reasons why you use should use Jenkins pipeline:

  • Jenkins pipeline is implemented as a code which allows multiple users to edit and execute the pipeline process.
  • Pipelines are robust. So if your server undergoes an unforeseen restart, the pipeline will be automatically resumed.
  • You can pause the pipeline process and make it wait to resume until there is an input from the user.
  • Jenkins Pipelines support big projects. You can run multiple jobs, and even use pipelines in a loop.

Jenkins pipeline concept

...

Introduction

Automatics 3.0 Custom API can be added by the partner by following the below steps

Steps to develop custom API 

  • Api Development 

Refer Automatics 3.0 - API Development to get more details on how to define Automatics API

  • Deploy the latest code to articraft

Jenkins Job can be triggered to deploy the latest code changes of project where new API is developed

Refer Jenkins Deployment Jobs for deployment jobs configurations.

  • Parse the project to update newly added API to data base

Utility parser need to be triggered for latest code changes to parse the new API and update the API details to micro service for test executions.

Refer Automatics 3.0 Utility Parser Jobs for Parser job configurations.

Automate the Deployment and Parsing jobs

For automating the deployment and parser jobs for Automatics, a new Pipeline job is introduced. What this pipeline job will do is it will invoke the existing jenkins freestyle jobs which does the deployment and API scanning in the correct order. The overview of jenkins pipeline job as well as the steps to create the Automatics pipeline job below.

Deployment and Parser Job creation

URL:<<Jenkins url>>

Go to the Dashboard of after logging in to Jenkins UI.

RDK-M Jenkins URL 

URL: https://rdkauto14.ccp.xcal.tv:8443/

    • Click on New Item in the Jenkins dashboard.

Image Modified

    • Click on the New Item and Create a job name.

Image Modified

Based on the jobs we need to select the type of projects. Once project created it will be listed in job list 

Created a generic pipeline. for all the utils and Parser. URL give below:

URL: https://rdkauto14.ccp.xcal.tv:8443/job/RDKM_CODE_DEPLOY_AND_3.0_API_Parser/.

User can find all the results in stage view of all utils and parser for kind reference. 

Image Removed

Image Removed

Let's now create a pipeline job using the below Groovy script:

  • Click on New Item in the Jenkins dashboard.

  • Set the “Job Name” as parent Job

  • Select the “Job Type” as Pipeline project.

  • Add the Groovy script as explained above and save the job.

...

    • Select Pipeline option from the List of options
    • Navigate to the Pipeline section of the job setup page.
    • The below is a sample groovy script for creating the pipeline job. What the below script does is invoke the existing jobs in sequential order. It should invoke the job deploy Automatics Core, RDB/RDKV Utils, and the jobs needs for Automatics 3.0 which are API Scan job for Automatics Core, Scriptless Automation, RDKB/ RDKV Utils projects.
Code Block
languagegroovy
titleAutomatics 3.0 Deployment and parser JobscriptthemeDJango
linenumberstrue
collapsetrue
node {
   
    stage ('Deployment DEPLOY_AUTOMATICS_CORE') {
           echoecho "Calling RDKM_DEPLOY_AUTOMATICS_COREDeployment-Automatics-Core Job"
           buildbuild job: 'RDKM_DEPLOY_AUTOMATICS_CORE<<Name_of_Deployment_Job_for_automatics_core>>', wait: true, propagate: true

    }

}
Code Block
languagegroovy
themeDJango
title Groovy Script For RDKM_DEPLOY_RDKB_TEST_UTILS
Groovy Script For RDKM_DEPLOY_RDKB_TEST_UTILS

...

    
    stage('Deployment RDKM_DEPLOY_RDKB_TEST_UTILS')

...

}
    

Groovy Script For RDKM_DEPLOY_RDKV_TEST_UTILS

node {

...

 {
       echo "Calling Deployment-RDKB-Utils Job"
       build job: '<<Name_of_Deployment_Job_for_rdkb_utils>>', wait: true, propagate: true
    }
    
    stage('Deployment RDKM_DEPLOY_RDKV_TEST_UTILS')

...

Pipeline Syntax For RDKM_AUTOMATICS_API_SCAN_FOR_AUTOMATICS_CORE

node {

...

 {
       echo "Calling Deployment-RDKV-Utils Job"
       build job: '<<Name_of_Deployment_Job_for_rdkv_utils>>', wait: true, propagate: true
    }
    
     stage('Run utility parser for Automatics Core') {
       echo "Calling RDKM_AUTOMATICS_API_SCAN_FOR_AUTOMATICS_CORE Job"

...


       build job: '

...

<<Name_

...

of_

...

Utility_

...

Parser_

...

for_

...

Automatics_

...

Core>>', wait: true, propagate:

...

Pipeline Syntax For RDKM_AUTOMATICS_API_SCAN_FOR_SCRIPTLESS_AUTOMATION

...

 true
    }
    
    stage('Run utility parser for Scriptless Automation')

...

 {
       echo "Calling RDKM_AUTOMATICS_API_SCAN_FOR_SCRIPTLESS_AUTOMATION Job"

...


       build job: '

...

<<Name_

...

of_

...

Utility_

...

Parser_

...

for_

...

scriptless_

...

automation>>', wait: true, propagate:

...

Pipeline Syntax For RDKM_AUTOMATICS_API_SCAN_FOR_RDKB_UTILS

node {     

 true
    }
    
      stage('Run utility parser for RDKB Test Utils')

...

 {
       echo "Calling RDKM_AUTOMATICS_API_SCAN_FOR_RDKB_UTILS Job"

...


       build job: '

...

<<Name_

...

of_

...

Utility_

...

Parser_

...

for_

...

rdkb_

...

utils>>', wait: true, propagate:

...

}
    Pipeline Syntax For RDKM_AUTOMATICS_API_SCAN_FOR_RDKV_UTILS

node

...

 true
    }
    
    stage('Run utility parser for RDKV Test Utils')

...

 {
       echo "Calling RDKM_AUTOMATICS_API_SCAN_FOR_RDKV_UTILS Job"

...


       build job: '

...

<<Name_

...

of_

...

Utility_

...

Parser_

...

for_

...

rdkv_

...

utils>>', wait: true, propagate:

...

 true
    }
}

Now, it’s time to give your job something to do. Click on the Build tab on the configure page.

ScreenshotImage Removed

This will take you to the build section. Click on the Add build step menu and select Execute shell.

ScreenshotImage Removed

We’re going to use a one-line shell step for this job.

ScreenshotImage Removed

Enter the single line of shell code and click Save.

Click Build Now. The job will run and complete almost immediately. Next, click the build number to see your results.

ScreenshotImage Removed

Next, click on Console Output, and you’ll see the shell message.

ScreenshotImage Removed

Your job is ready for scheduling!

Add a Schedule to a Jenkins Job

Head back to the job configuration and click the Build Triggers tab.

ScreenshotImage Removed

Now, check the Build periodically box in the Build Triggers section.

ScreenshotImage Removed

This will open the scheduling text area.

ScreenshotImage Removed

Next, let’s set the job to run every five minutes.

Enter H/5 * * * * into the box, click Save, and reopen the configuration. Jenkins will show you when the job will run.

ScreenshotImage Removed

Save the job again and wait a few minutes. Depending on the value Jenkins selects for H, the job will run after a few minutes.

Here is a screenshot of a couple of builds on our system. You can see that the first build corresponds to the time shown above on the configure page.

ScreenshotImage Removed

The timestamps show that you’ve scheduled a job to run every five minutes.

Wait for a bit longer and you will see that it continues to run every five minutes.

...