Created
February 3, 2026 17:03
-
-
Save kpratikshak/0c860f77065e8fe05790c6ef5aaa0fc6 to your computer and use it in GitHub Desktop.
Bash commands to install jenkins on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Basic Jenkins commands | |
| http://localhost:8080 | |
| # Download Jenkins CLI | |
| wget http://localhost:8080/jnlpJars/jenkins-cli.jar | |
| # Test CLI connection | |
| java -jar jenkins-cli.jar -s http://localhost:8080 help | |
| # List available commands | |
| java -jar jenkins-cli.jar -s http://localhost:8080 help |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get initial admin password | |
| sudo cat /var/lib/jenkins/secrets/initialAdminPassword | |
| # Or for Docker installations | |
| docker exec jenkins_container cat /var/jenkins_home/secrets/initialAdminPassword | |
| # Access Jenkins web interface | |
| # Browse to http://localhost:8080 | |
| # Enter the initial admin password | |
| # Install suggested plugins or select custom plugins |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Update package manager and install Java | |
| sudo apt update | |
| sudo apt install fontconfig openjdk-21-jre | |
| java -version | |
| # Add Jenkins GPG key | |
| sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \ | |
| https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | |
| # Add Jenkins repository | |
| echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \ | |
| https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ | |
| /etc/apt/sources.list.d/jenkins.list > /dev/null | |
| # Install Jenkins | |
| sudo apt update && sudo apt install jenkins | |
| # Start Jenkins service | |
| sudo systemctl start jenkins | |
| sudo systemctl enable jenkins |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create job from XML configuration | |
| java -jar jenkins-cli.jar -auth user:token create-job my-job < job-config.xml | |
| # Create simple freestyle job via web UI: | |
| # 1. Click "New Item" | |
| # 2. Enter job name | |
| # 3. Select "Freestyle project" | |
| # 4. Configure build steps | |
| # 5. Save configuration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # List all jobs | |
| java -jar jenkins-cli.jar -auth user:token list-jobs | |
| # List jobs with pattern matching | |
| java -jar jenkins-cli.jar -auth user:token list-jobs "*test*" | |
| # Get job configuration | |
| java -jar jenkins-cli.jar -auth user:token get-job my-job > job-config.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Trigger & Build jenkins jobs | |
| java -jar jenkins-cli.jar -auth user:token build my-job | |
| # Build with parameters | |
| java -jar jenkins-cli.jar -auth user:token build my-job -p PARAM=value | |
| # Build and wait for completion | |
| java -jar jenkins-cli.jar -auth user:token build my-job -s -v | |
| # Build and follow console output | |
| java -jar jenkins-cli.jar -auth user:token build my-job -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment