实习日志(第六周)

Jenkins常用插件

  1. 添加Github授权认证(Github OAuth Plugin)
    1. 在全局安全配置中,选择安全领域为GitHub验证插件。
    2. 要配置的设置有:GitHub Web URI,GitHub API URI,客户端ID,客户端密钥和OAuth范围。
    3. 如果您使用GitHub Enterprise,则API URI为https://ghe.example.com/api/v3
    4. 推荐的最低GitHub OAuth范围为:org,user:email。
      通过脚本控制台自动配置安全领域

      import hudson.security.SecurityRealm
      import org.jenkinsci.plugins.GithubSecurityRealm
      String githubWebUri = 'https://github.com'
      String githubApiUri = 'https://api.github.com'
      String clientID = 'someid'
      String clientSecret = 'somesecret'
      String oauthScopes = 'read:org'
      SecurityRealm github_realm = new GithubSecurityRealm(githubWebUri, githubApiUri, clientID, clientSecret, oauthScopes)
      //check for equality, no need to modify the runtime if no settings changed
      if(!github_realm.equals(Jenkins.instance.getSecurityRealm())) {
      Jenkins.instance.setSecurityRealm(github_realm)
      Jenkins.instance.save()
      }

      通过脚本控制台自动配置授权策略

      import org.jenkinsci.plugins.GithubAuthorizationStrategy
      import hudson.security.AuthorizationStrategy
      //permissions are ordered similar to web UI
      //Admin User Names
      String adminUserNames = 'samrocketman'
      //Participant in Organization
      String organizationNames = ''
      //Use Github repository permissions
      boolean useRepositoryPermissions = true
      //Grant READ permissions to all Authenticated Users
      boolean authenticatedUserReadPermission = false
      //Grant CREATE Job permissions to all Authenticated Users
      boolean authenticatedUserCreateJobPermission = false
      //Grant READ permissions for /github-webhook
      boolean allowGithubWebHookPermission = false
      //Grant READ permissions for /cc.xml
      boolean allowCcTrayPermission = false
      //Grant READ permissions for Anonymous Users
      boolean allowAnonymousReadPermission = false
      //Grant ViewStatus permissions for Anonymous Users
      boolean allowAnonymousJobStatusPermission = false
      AuthorizationStrategy github_authorization = new GithubAuthorizationStrategy(adminUserNames,
      authenticatedUserReadPermission,
      useRepositoryPermissions,
      authenticatedUserCreateJobPermission,
      organizationNames,
      allowGithubWebHookPermission,
      allowCcTrayPermission,
      allowAnonymousReadPermission,
      allowAnonymousJobStatusPermission)
      //check for equality, no need to modify the runtime if no settings changed
      if(!github_authorization.equals(Jenkins.instance.getAuthorizationStrategy())) {
      Jenkins.instance.setAuthorizationStrategy(github_authorization)
      Jenkins.instance.save()
      }
  2. 添加构建的选择参数(Extended Choice Parameter plugin)
    在创建构建时勾选参数化构建过程,然后在添加参数里选择choice parameter,在里面填写一下代码。
import org.boon.Boon;
def jsonEditorOptions = Boon.fromJson(/{
        disable_edit_json: true,
        disable_properties: true,
        no_additional_properties: true,
        disable_collapse: true,
        disable_array_add: true,
        disable_array_delete: true,
        disable_array_reorder: true,
        theme: "bootstrap2",
        iconlib:"fontawesome4",
        schema: {
          "type": "object",
          "title": "Name",
          "properties": {
            "first_name": {
              "type": "string",
              "propertyOrder" : 1
            },
            "last_name": {
              "type": "string",
              "propertyOrder" : 2
            },
            "full_name": {
              "type": "string",
              "propertyOrder" : 3,
              "template": "{{fname}} {{lname}}",
              "watch": {
                "fname": "first_name",
                "lname": "last_name"
              }
            }
          }
        },
        startval: {
            "first_name" : "John",
            "last_name" : "Doe",
            "full_name" : "John Doe"
        }
}/);
  1. Gerrit触发器(Gerrit Trigger)
    在Gerrit中,每当有代码push到Git,就会在Gerrit中创建一个patch set。
    基于这个patch set,在Jenkins中,就可以自动触发一次构建。

    1. 将Jenkins的用户添加到Gerrit服务器中并设置权限
      在Gerrit页面,Admin->Groups->Non-Interactive Users->Add
    2. 在Jenkins中设置Gerrit服务器的参数
      安装插件成功后,在Jenkins界面,单击左侧菜单”系统管理Manage Jenkins”,将出现”Gerrit Trigger”。
      单击”Gerrit Trigger”进入。
      “Add New Server”给出Gerrit服务器的名字MyGerritServer,
      并选中”Gerrit Server with Default Configurations”,单击”OK”
      输入信息如下:
      hostname: gerrit.ericsson.se
      frontend URL: https://gerrit.ericsson.se/
      SSH Port: 29418
      username: userbbauto in Ericsson
      E-mail: xiangbin.han@ericsson.com
      SSH Keyfile: /home/myusername/.ssh/id_rsa
      SSH Keyfile Password: **
    3. 在Jenkins中创建job参数
    4. 在“源码管理”部分勾选Git,配置如下信息:
      (1)Repositories区域
      Repository URL:ssh://username@gerrit.ericsson.se:29418/bbauto/bba
      Credentials:…
      (2)Branches to build区域
      Branch Specifier(blank for ‘any’):可以为空,master
      (3)Additional Behaviours区域
      单击Add按钮,选择Strategy for choosing what to build
      Choosing stategy:选择Gerrit Trigger
    5. 在“构建触发器”部分勾选Gerrit event
      (1)Choosing a Server:
      选择MyGerritServer
      (2)Trigger on:
      Patchset Created
      Change Merged
      Draft Published
      (3)Gerrit Project
      Plain, bbauto/bba, Plain, master
    6. 在”构建“部分,选择Execute shell(非Maven项目)
      Command:
  2. BearyChat插件

    1. 获取BearyChat帐户:https://bearychat.com/
    2. 在Jenkins服务器上安装此插件
    3. 完成jenkins机器人配置http://yourteam.bearychat.com/robots
  3. 发邮件( Email-ext plugin)
    此插件允许配置电子邮件通知的每个方面。 可以自定义发送电子邮件的时间,谁应该收到邮件以及电子邮件的内容。
    1. 触发器 - 选择应该发送电子邮件通知的条件。
    2. 内容 - 指定每个触发的电子邮件主题和正文的内容。
    3. 收件人 - 指定触发时应接收电子邮件的人员。
  4. 参数化构建(Build With Parameters Plugin)
    1. 允许用户为网址中的构建提供参数,提示在触发作业之前进行确认。
      该插件暴露了 JENKINS/job/ JOB / parambuild url以使用参数触发构建。
  5. 定时周期执行任务(Cron Column Plugin)
    查看列显示可以在作业中配置的cron触发器表达式
  6. 添加python支持(Python Plugin)
    添加执行python脚本作为构建步骤的功能。 除此之外,这个插件非常像标准的shell脚本支持。
  7. Markdown支持(PegDown Formatter Plugin)
    1. 使用PegDown在Jenkins的描述中格式化Markdown语法,例如视图,作业,构建,系统消息等。
    2. 禁用HTML以防止XSS
    3. 启用/禁用所有PegDown扩展
  8. Flow 插件
    1. 此插件旨在处理复杂的构建工作流程(又称构建管道),
    2. 作为Jenkins中的专用实体。构建流程使您能够使用专用DSL来定义上级流项目来管理作业编排和链接规则。
    3. 这种DSL使流定义非常简洁易读。主要工作对于管道是不了解的,因为一切都被外部化了。
    4. 这个插件唯一缺少的是它不支持显示器上的图形可视化。
    5. 有一个Build Graph View插件,但它不是为了这个用途。
    6. 如果图形视图与您无关,那么这可以是最好的插件。否则去定期分散配置。
  9. Monitor插件
    1. 显示所选作业的状态和进度,使用AJAX每隔几秒自动更新视图。 不需要“启用自动刷新”。
    2. 显示可能负责“打破构建”的人员的姓名。
    3. 支持索赔插件,以便您可以查看谁在修复损坏的构建
    4. 支持查看作业过滤器,以便您可以轻松地创建构建监视器“慢速构建”,“仅发生故障”等。
    5. 支持构建故障分析器,使您不仅知道谁,而且知道什么打破了构建; 更多在这里
    6. 支持CloudBees文件夹插件,以便您可以拥有项目和团队特定的嵌套构建监视器; 更多在这里
    7. 使用的字体的数量和字体大小可以轻松自定义,使其适应不同大小的屏幕。
    8. UI配置存储在cookie中,可以在您办公室的每个屏幕上显示不同数量的列,并使用不同的字体大小。
    9. 可以在色盲模式下工作
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值