Skip to content

Jenkins

Wenliang Zhang edited this page May 8, 2019 · 2 revisions

Installation

  1. Download the latest stable version.
  2. scp to the server and install it.
  3. Install plugins like email-ext, git etc.
  4. Make sure to set ssh port to 22 for gitlab, if the default port is not 22.
    $ grep Port /etc/ssh/ssh*_config
    
    $ cat ~/.ssh/ssh_config
    Host *
      Port 22
        

Dependencies

Jenkins plugins can be instaled online or offline. Offline mode is tedious.

Download plugins from https://updates.jenkins-ci.org/download/plugins/.

Install them according to the top-sort order.

email-ext-recipients-column: javadoc maven-plugin

emailext-template: email-ext

===

email-ext: junit mailer token-macro matrix-project structs script-security

matrix-project: junit

junit: workflow-api script-security script-security-api structs

maven-plugin: apache-httpcomponents-client-4-api jsch

===

git: git-client workflow-scm-step

jsch: ssh-credentials

ssh-credentials: credentials

mailer: display-url-api

workflow-api: scm-api

token-macro: workflow-step-api

workflow-step-api: structs

===

postbuildscipt: none

git-client: none

workflow-scm-step: none

credentials: none

apache-httpcomponents-client-4-api: none

javadoc: none

display-url-api: none

scm-api: none

script-security: none

structs: none

Tasks

$PROJECT_NAME- Build # $BUILD_NUMBER - $BUILD_STATUS:<BR>
<BR>
Build warning(s), error(s) and test failure(s):<BR>
${BUILD_LOG_REGEX,regex="(CMake Warning at |warning: |error: |Completed: Failed |Failing test)", showTruncatedLines=false, matchedLineHtmlStyle="color:#FF0000", defaultValue="nothing"}
<BR>
Check console output at $BUILD_URL to view the details.<BR>

Add new node

  1. 需要在 Jenkins 的管理页面增加一个 Node。假设以 JNLP 方式启动代理。
  2. 在 Node 上准备工作目录和代理。
    $ sudo mkdir -p /data/jenkins
    $ sudo chown -R yourname:yourgroup /data/jenkins/
    
    $ sudo ln -s /data/jenkins /var/lib/jenkins
    $ sudo chown -R yourname:yourgroup /var/lib/jenkins
        
  3. 从 Jenkins 管理页面下载 agent.jar 到 /data/jenkins。
  4. 写个类似下面的脚本,启动 agent:
    $ more run.sh 
    #!/usr/bin/env bash
    java -jar agent.jar -jnlpUrl http://jenkins/computer/XXX/slave-agent.jnlp -secret YYY 
        
  5. 启动脚本或完善一下做到 crontab 里头。
$ nohup run.sh 
Clone this wiki locally