https://www.jenkins.io/doc/book/installing/linux/
Install Java
sudo apt update
sudo apt install openjdk-8-jdk
Install Jenkins LTS Ubuntu
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
Tests:
https://ip:8080 - jenkins
https://ip:8080/restart - reboot jenkins
cd /usr/share/jenkins
sudo mv jenkins.war jenkinsold.war
sudo wget https://link/jenkins.war
sudo service jenkins restart
Build > Configure > General > Discard old builds > Max # of builds to keep > 10
Manage Jenkins > Configure System > Publish over SSH > add servers & keys
Job > Configure > Post-build Action > Send build artefacts over SSH
Job > Configure > General > Disable this job
Install Plagins:
SSH Agent
SSH Slave
Manage Jenkins > Manage Nodes > New Node
Configuring jobs to run on specific nodes:
Job > Configure > General > Restrict where this project can be run > Label expression
wget https://link:8080/jnlpJars/jenkins-cli.jar
java -jar jenkins-cli.jar -auth username:password -s htttp://link:8080 help
or
java -jar jenkins-cli.jar -auth username:token -s htttp://link:8080 help
or
export JENKINS_USER_ID=user
export JENKINS_API_TOKEN=token
java -jar jenkins-cli.jar -s htttp://8080 help
Export Job to file .xml
java -jar jenkins-cli.jar -auth username:token -s htttp://link:8080 get-job job1 > job1.xml
Import Job from file .xml
java -jar jenkins-cli.jar -auth username:token -s htttp://link:8080 create-job job1 < job1.xml
Trigger builds remotely - This feature provides flexibility that allows triggering a job from the script, command line.
curl -X POST "https://username:api-token@JENKINS_URL:8080/job/Example/build"
or
wget --auth-no-challenge --http-user=username --http-password=api_token http://JENKINS_URL:8080/job/Trigger_Remote_Demo/build?token=My-token
Build after other projects are built - If your project depends on another project build
Build periodically - You can create a schedule (or multiple schedules) for Jenkins to build periodically or on a specific date/time.
Poll SCM - You can create a schedule for Jenkins to check the source code changes, if there are updates to checkout the latest code down, and then execute the build action.
github plugin - Execute the build action after push changes.
Build Options > General > Github project
Build Options > General > Build Triggers > Github hook trigger for GITScm polling
Github > Project > Settings > Webhook > Payload URL > JENKINS_URL:8080/github-webhook
Github > Project > Settings > Webhook > Content type > application/json