JenkinsCI - henk52/knowledgesharing GitHub Wiki
- ACL: Anti corruption layer
-
/var/lib/jenkins/jobs
-
/var/lib/jenkins/plugins
-
/var/log/jenkins/jenkins.log
Other CI servers
Notes on CI/CD
wget --no-proxy http://localhost:8080/jnlpJars/jenkins-cli.jar
java -jar jenkins-cli.jar -s http://localhost:8080/ help
- generate the ssh keys: ssh-keygen -trsa
- Create the user you are executing as, in the Jenkins web server
- cat ~/.ssh/id_rsa.pub
copy the public key content to the http://localhost:8080/user/YOUR_USER/configure
java -jar jenkins-cli.jar -s http://localhost:8080/ get-job MyTemplateJob > template.xml
- Create a job.xml file.
java -jar jenkins-cli.jar -s http://localhost:8080/ create-job SmokeTest < smoketest.xml
Add the node names to the /etc/hosts
- Click: Manage Jenkins
- Click: Manage Nodes
- Click: New Node
- Node name: XXX
- Dumb ????
- Click: Ok
- fill in
- remote root directory: /var/lib/jenkins
- Labels: nightly
- Usage:
- Launch method: Launch slave agent ... ssh
- x
- Kind: ssh username with private key
- Scope: Global
- Username: jenkins
- description:
- Private Key: From the Jenkins master ~/.ssh
- Click Add.
- Availability:
Please note, you have to have set the credentials for jenkins, prior to running this.
java -jar jenkins-cli.jar -s http://localhost:8080/ create-node < node_tst3.xml
<?xml version="1.0" encoding="UTF-8"?>
<slave>
<name>NODE_NAME</name>
<description>NODE DESCRIPTION.</description>
<remoteFS>/var/lib/jenkins</remoteFS>
<numExecutors>3</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]">
<host>NODE_HOST_NAME</host>
<port>22</port>
<credentialsId>CREDENTIAL_ID_PREVIOUSLY_CREATED</credentialsId>
<maxNumRetries>0</maxNumRetries>
<retryWaitTime>0</retryWaitTime>
</launcher>
<label>OPTIOANL_LABELS</label>
<nodeProperties/>
</slave>
Add '-Xmx1048m' to the JENKINS_JAVA_OPTIONS in /etc/sysconfig/jenkins
Then restart the jenkins service.
There are two ways to do this:
- Slave copies to a repo and master copies from that repo.
- All slaves and Master must have credentials to access the repo
- Master copies from slave.
- The Master must know where the slave stores the data
- Slave copy to master.
- The slave must have write access
-
How can slave copy data to repo:
- scp (which requires credentials)
- nfs mount
- web interface
- sftp
-
Slave copies data to repo (with a predefined naming convention)
-
Master copies data from repo.
-
Master removes data from repo.
Setup:
- On repo
- Create user: cimstr
- create ~cimstr/.ssh/authorizedkey with public key from jenkins master
- create user+group: cislave
- create ~cislave/.ssh/authorizedkey with public key from jenkins slave(s)
- mkdir /var/cirepo
- chown -R cimstr:cislave /var/cirepo
- On slave(s)
- write the common pub+priv key pair from puppet repo.
- On Master
- Nothing to be done.
-
Declarative: You use the plugins and base language functions.
-
Scripted: You write groovy scripting of execution.
Grafana data:
- jenkins.job.waiting.duration.m1_rate
- jenkins.job.queuing.duration.m1_rate
- jenkins.plugins.withUpdate (alert when > 0)
<?xml version="1.0" ?>
<testsuites>
<testsuite errors="0" failures="0" name="first test suite" tests="1">
<testcase classname="some.class.name" name="Test1" time="123.456000">
<system-out>
standard out of the test run
</system-out>
<system-err>
standard error of the test run
</system-err>
</testcase>
</testsuite>
</testsuites>
Stopping and starting the jenkins server fixed this.
- service jenkins stop
- service jenkins start
Fix: update jenkins' ~/.ssh/known_hosts, with the remote key (perhaps interactively ssh to the host).
Host key verification failed.
fatal: Could not read from remote repository.
See also: You can set the node for manual verification and then switch to automatic afterwards...
- Put in breakers so that if e.g. build statistics can't be created, then it should not break the pipeline.