Jenkins

1 install

1 jdk8 or jdk11

  • Linux写入/etc/profile or windows系统环境变量配置

    # step install on Linux
    curl -L -b "oraclelicense=a" -O http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
    mkdir /usr/jdk8
    tar -zxf jdk-8u191-linux-x64.tar.gz -C /usr/jdk8
    java -version
    rm -f jdk-8u191-linux-x64.tar.gz
    # uninstall
    apt remove default-jdk
    
    # set java path
    # install for Single User
    # Check if JAVA_HOME is already set
    echo $JAVA_HOME
    # install java
    # install java
    vi ~/.bashrc OR vi ~/.bash_profile `export JAVA_HOME=/usr/java/jdk1.8.0_191`
    source ~/.bashrc OR source ~/.bash_profile
    echo $JAVA_HOME
    
    # Install for all users :
    # Login as root or execute commands with sudo

2 git

3 Tomcat / Maven / Gradle / Ant if needed

Maven

Tomcat

  • install

  • configuration

  • access

  • 开启自启动

4 jenkins

2 Configure

1 System Configuration & global security & global tools & users

2 plugin related

  • change update site if needed

http://mirror.xmission.com/jenkins/updates/current/update-center.json

  • 一些推荐插件

    • Git / Git Parameter / Rebuilder / GitHub Branch Source

    • Mailer Plugin / Email Extension Plugin

    • Timestamper、Ansicolor、Workspace Cleanup

    • Monitoring、Project statistics、Test Result Analyzer Plugin

    • Matrix Authorization Stratery Plugin

    • ThinBackup

    • Folders

    • ...

3 change httpPort

locate jenkins.xml--> change --httpPort=8888

4 smtp server

basic

  1. register 163 or other email for 授权码

  2. System Admin email address must be same as below SMTP Username

  3. ==SMTP Password是客户端授权码不是邮箱密码==

  4. Charset / Content Type / Recipients / Subject / Maxinum Attachment Size / Content / Triggers if needed

  5. Item add post-build action -> E-mail Notification

Then test email funciton

advanced

  1. finish basic email configuration

  2. ==check Enable Debug Mode==

  3. add Always Trigger

  4. readd Recipient List (==maybe bug==)

  5. change content type to html

  6. ==change content templete==

  7. Attach Build Log

  8. item add post-build action -> Editable Email Notification

5 configure DingTalk

3 构建Item

  • 前置条件

    1. 将Jenkins的秘钥拷贝到Git服务器,以使其在拉取代码的时候免密码操作

    2. 将Jenkins的秘钥拷贝到tomcat服务器,以使其在同步等操作的时候免密码

  • 命名规则:项目前缀 - 说明 - Job类型

  • 配置Item(SCM、Build Triggers、Pre/Post-actions等)

    • SCM

      • System Configuration -> add Github server -> add secret text凭据 -> github创建token (check repo、admin:repo_hook) -> 添加凭据 -> 测试jenkins和Github 连通性

      • Item check github项目 -> 项目url

      • Item check git -> url -> github登录凭证

        git开头的url才需要加公钥私钥

        公钥加入github,私钥加入jenkins

        ssh-keygen不是命令则需要加入环境变量

      • check GitHub hook trigger for GITScm polling

        • ==webhook必须是外网可以访问的地址,github才能通知到jenkins==

      • check Use secret text or file -> add secret text ?????

        then push to github for auto-build test

Last updated