Navigation :
Setup
List of Labs
-
Basics Labs
-- Jenkinsfile
-- Declarative vs Scripted Pipeline
-- Node/Stage/Step/Groovy
-- Git vs Checkout SCM
-- Tools
-- Shell Script
-- Credentials
-- Stash and Unstash
-- Clean Workspace
-- Parameters
-- Strings
-- Parallel
-
Shared Pipeline Library Labs
-- Using Shared Library
-- Example
-- Closure vs Map
-
Advanced Labs
-- Build Name
-- Remote Loader
-- Lockable Resources
-- Config File Provider
-- Script Approval vs Sandbox
-- SSH Agent
-- Job DSL
-- Flow Control
-
Enterprise Labs
-- Config-Driven Pipeline Plugin
-- Moduler Pipeline Library
-- Jenkins Template Engine
Pipeline Steps
- retryWithPrompt
- retryAndReturn
- createGitBranchV1
- createGitBranchV2
SSH Agent
SSH Agent
node {
step([$class: 'WsCleanup'])
sshagent(['ssh']) {
git branch: 'test', url: 'https://github.com/nrayapati/kcdc_test.git'
sh "ssh-keyscan -H github.com >> ~/.ssh/known_hosts"
sh "git remote set-url origin git@github.com:nrayapati/kcdc_test.git"
sh "git config user.email naresh.rayapati@gmail.com"
sh "git config user.name nrayapati"
sh 'git checkout -b kcdc'
sh 'git push origin kcdc'
}
}
Commands to generate key:
https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Copy public key to your account on github
pbcopy < ~/.ssh/id_rsa.pub
# Save private key in Jenkins
pbcopy < ~/.ssh/id_rsa