The edas-jenkins-plugin plug-in is incorporated in Jenkins. This plug-in allows you to use Jenkins to continuously deploy applications to Enterprise Distributed Application Service (EDAS). The Jenkins console provides a graphical user interface (GUI) for you to deploy applications. This topic shows you how to deploy applications in the Jenkins console. You can create a pipeline script to deploy an application or use Job-dsl to create a template so that you can generate a deployment job by using the template.

Prerequisites

The Job-dsl plug-in is installed.

Install edas-jenkins-plugin

  1. Download the installation package of edas-jenkins-plugin.
  2. Log on to Jenkins. On the Jenkins homepage, click Manage Jenkins. On the Manage Jenkins page, click Manage Plugins.
  3. On the Plugin Manager page, select the Advanced tab. In the Upload Plugin section, click Select file, select the plug-in that you have downloaded, and then click Upload.
  4. On the Installing Plugins/Upgrades page, wait until the plug-in is installed.

Configure account information

  1. Log on to Jenkins. On the Jenkins homepage, click Manage Jenkins. On the Manage Jenkins page, click Configure System.
  2. In the Deploy to EDAS section, configure account information and click Add. Then, click Advanced and enter region information.
    Deploy into EDAS
    Parameter Description
    EDAS credentials name Specify a name for the AccessKey pair.
    EDAS Access Key ID Enter the AccessKey ID of your Alibaba Cloud account. For information about how to create an AccessKey pair, see Create an AccessKey pair.
    EDAS Access Key Secret Enter the AccessKey secret of your Alibaba Cloud account. For information about how to create an AccessKey pair, see Create an AccessKey pair.
    EDAS Region Select the region ID where you want to deploy your application, for example, cn-hangzhou.
    Endpoint This parameter is applicable to Apsara Stack. Before you use Jenkins on Apsara Stack, set the value to the EDAS endpoint. To obtain an endpoint, contact EDAS technical support.
    Note If you use Jenkins on Alibaba Cloud, this parameter is not required.
  3. After the preceding parameters are configured, click Ping EDAS in the Deploy to EDAS section. If success appears, the account information is configured.
    Note You can click Add to configure multiple accounts for which EDAS is activated.

Create a freestyle project in Jenkins to deploy an application

  1. Log on to Jenkins. On the Jenkins homepage, click New Item.
  2. In the Enter an item name field, enter a project name. Then, select Freestyle project and click OK.
  3. In the Post-build Actions section, click Add post-build actions. Then, select Deploy to EDAS from the drop-down list.
  4. In the Deploy to EDAS section, click Add and select a cluster from the drop-down list to deploy your application.
    Add a project to deploy an application
    Parameter Description
    EDAS ECS Application Use Jenkins to upgrade an application that has been deployed in an Elastic Compute Service (ECS) cluster. For more information about configuration parameters, see Deploy an application to an ECS cluster.
    Create EDAS ECS Application Use Jenkins to create and deploy an application in an ECS cluster. For more information about configuration parameters, see Create and deploy an application in an ECS cluster.
    EDAS K8s Application Use Jenkins to upgrade an application that has been deployed in a Container Service Kubernetes cluster. For more information about configuration parameters, see Deploy an application to a Container Service Kubernetes cluster.
    Create EDAS K8s Application Use Jenkins to create and deploy an application in a Container Service Kubernetes cluster. For more information about configuration parameters, see Create and deploy applications in a Container Service Kubernetes cluster.
  5. After the configuration is complete, click Save or Apply in the lower-left corner of the page.
  6. In the left-side navigation pane of the project details page, click Build Now to build the project.
    Build a project
    In the Build History section, the build records of the project appear. You can click the build record that you want to view. Then, the details page of the build record appears. Project build details

Use edas-jenkins-plugin to deploy an application to EDAS

The edas-jenkins-plugin plug-in supports the built-in Snippet Generator of Jenkins Pipeline. This allows you to build a pipeline in Jenkins and deploy an application to EDAS.

  1. Log on to Jenkins. On the Jenkins homepage, click New Item.
  2. In the Enter an item name field, enter a project name. Then, select Pipeline and click OK.
  3. In the Pipeline section, click Pipeline Syntax.
    Note If you have created a pipeline, you can click the pipeline name in the project list to go to the pipeline management page. In the left-side navigation pane, click Pipeline Syntax. The Snippet Generator page appears.
  4. On the Snippet Generator page, select edasClient: Deploy into EDAS from the Sample Step drop-down list. Then, click Add next to Application Setup and select a deployment mode from the drop-down list based on the cluster type and application type.
  5. Configure the deployment parameters. For more information about the configurations, see Configure the relevant parameters in scenarios where edas-jenkins-plugin in Jenkins is used to deploy an application.
  6. After the parameters are configured, click Generate Pipeline Script. Then, replicate the generated pipeline script.
    Generate Pipeline Script
  7. In the left-side navigation pane, click Back to return to the pipeline management page. In the left-side navigation pane, click Configure. Then, enter the script in the Pipeline section, as shown in the following figure.
    Note In the following figure, replace the content in the orange box with the script generated in the preceding step.
    pipeline
  8. After the configuration is complete, click Save or Apply in the lower-left corner of the page.
  9. In the left-side navigation pane of the project details page, click Build Now to build the project.
    In the Build History section, the build records of the project appear. You can click the build record that you want to view. Then, the details page of the build record appears.

Use Job-dsl to build a deployment job

In Jenkins, you can use Job-dsl to build a job template. This way, you can build a deployment job by using the template.

  1. Log on to Jenkins. On the Jenkins homepage, click New Item.
  2. In the Enter an item name field, enter a project name. Then, select Freestyle project and click OK.
  3. In the Build section, click Add build step and select Process Job DSLs from the drop-down list.
    Note If you have created a pipeline, you can click the pipeline name in the project list to go to the pipeline management page. In the left-side navigation pane, click Pipeline Syntax. The Snippet Generator page appears.
    Process Job DSLs
  4. In the Process Job DSLs section, click Use the provided DSL script. In the DSL Script field, enter the configuration script.
    job('edas') {    //The name of the job that you want to build.
      publishers { //The type of the EDAS plug-in.
        edasClient { //The name of the client that calls the EDAS plug-in.
          deployApplication('', '', '', '', '') //The method that is used to call the application to be deployed in EDAS.
        }
      }
    }
    The following deployment methods are supported:
    //Deploy an application to an ECS cluster.
    void deployApplication(
            String namespace,
            String credentialsString,
            String group,
            String appId,
            String targetObject);
    
    void deployApplication(
            String namespace,
            String credentialsString,
            String group,
            String appId,
            String targetObject,
            String versionLabelFormat,
            String versionDescriptionFormat,
            String batch,
            String batchWaitTime,
            String releaseType);
    
    //Create and deploy an application in an ECS cluster.
    void insertApplication(
            String namespace,
            String credentialsString,
            String applicationName,
            String packageType,
            String clusterId,
            String targetObject,
            String ecuInfo);
    
    void insertApplication(
            String namespace,
            String credentialsString,
            String applicationName,
            String packageType,
            String clusterId,
            String targetObject,
            String ecuInfo,
            String versionLabelFormat,
            String versionDescriptionFormat,
            String buildPackId,
            String healthCheckUrl);
    
    //Deploy an application to a Container Service Kubernetes cluster.
    void deployK8sApplication(
            String namespace,
            String credentialsString,
            String appId,
            String targetObject,
            Boolean image);
    
    void deployK8sApplication(
            String namespace,
            String credentialsString,
            String appId,
            String targetObject,
            Boolean image,
            String edasContainerVersion,
            String webContainer,
            String jdk,
            String versionLabelFormat,
            String envs,
            String startupCommand,
            String args,
            String cpuLimit,
            String memoryLimit,
            String cpuRequest,
            String memoryRequest,
            String replicas,
            String postStart,
            String preStop,
            String readiness,
            String liveness,
            String updateStrategy);
    
    //Create and deploy an application in a Container Service Kubernetes cluster.
    void insertK8sApplication(
            String namespace,
            String credentialsString,
            String applicationName,
            String packageType,
            String clusterId,
            String targetObject,
            String k8sNamespace,
            String jdk);
    
     void insertK8sApplication(
            String namespace,
            String credentialsString,
            String applicationName,
            String packageType,
            String clusterId,
            String targetObject,
            String k8sNamespace,
            String jdk,
            String descFormat,
            String edasContainerVersion,
            String webContainer,
            String versionLabelFormat,
            String envs,
            String startupCommand,
            String args,
            String cpuLimit,
            String memoryLimit,
            String cpuRequest,
            String memoryRequest,
            String replicas,
            String postStart,
            String preStop,
            String readiness,
            String liveness);
  5. After the configuration is complete, click Save or Apply in the lower-left corner of the page.
  6. In the left-side navigation pane of the project details page, click Build Now to build the project.
    In the Build History section, the build records of the project appear. You can click the build record that you want to view. Then, the details page of the build record appears.

More information

Configure the relevant parameters in scenarios where edas-jenkins-plugin in Jenkins is used to deploy an application