Posts for: #Jenkins

Example secret file and sshagent

Example using a secret file as a variable and sshagent node{ stage('CertCheck'){ withCredentials([file(credentialsId: '19df427c-0000-1234-9876-161969d46b18', variable: 'pemfile')]) { sh 'ls -ahl' echo "${pemfile}" sh "cat ${pemfile}" } } stage('SSHSomething'){ sshagent(['c4cc169b-aaaa-bbbb-ffff-543a157f6ad5']) { sh "ssh user@ssh.example.com 'ifconfig'" } } } Stage CertCheck [in_jenkins-dsl-test_hw_test-L6OPGZSILNYU4LFJKDMY4AGUBMSB2FT3Z3UAW66ODUIPZN4WUNBA] Running shell script + ls -ahl total 33K drwxr-xr-x 2 jenkins jenkins 2 Sep 8 21:03 . drwxr-xr-x 28 jenkins jenkins 28 Sep 9 01:52 .. **** [in_jenkins-dsl-test_hw_test-L6OPGZSILNYU4LFJKDMY4AGUBMSB2FT3Z3UAW66ODUIPZN4WUNBA] Running shell script + cat **** -----BEGIN CERTIFICATE----- MIID/DCCAuSgAwIBAgIBSzANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNTAyMDUyMjAzNTBaFw0y MDAzMDUyMjAzNTBaMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEgMB4GA1UEAwwXQW1hem9uIFJE UyB1cy13ZXN0LTIgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDM H58SR48U6jyERC1vYTnub34smf5EQVXyzaTmspWGWGzT31NLNZGSDFaa7yef9kdO mzJsgebR5tXq6LdwlIoWkKYQ7ycUaadtVKVYdI40QcI3cHn0qLFlg2iBXmWp/B+i Z34VuVlCh31Uj5WmhaBoz8t/GRqh1V/aCsf3Wc6jCezH3QfuCjBpzxdOOHN6Ie2v xX09O5qmZTvMoRBAvPkxdaPg/Mi7fxueWTbEVk78kuFbF1jHYw8U1BLILIAhcqlq x4u8nl73t3O3l/soNUcIwUDK0/S+Kfqhwn9yQyPlhb4Wy3pfnZLJdkyHldktnQav 9TB9u7KH5Lk0aAYslMLxAgMBAAGjZjBkMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMB Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBT8roM4lRnlFHWMPWRz0zkwFZog1jAfBgNV HSMEGDAWgBROAu6sPvYVyEztLPUFwY+chAhJgzANBgkqhkiG9w0BAQUFAAOCAQEA JwrxwgwmPtcdaU7O7WDdYa4hprpOMamI49NDzmE0s10oGrqmLwZygcWU0jT+fJ+Y pJe1w0CVfKaeLYNsOBVW3X4ZPmffYfWBheZiaiEflq/P6t7/Eg81gaKYnZ/x1Dfa sUYkzPvCkXe9wEz5zdUTOCptDt89rBR9CstL9vE7WYUgiVVmBJffWbHQLtfjv6OF NMb0QME981kGRzc2WhgP71YS2hHd1kXtsoYP1yTu4vThSKsoN4bkiHsaC1cRkLoy 0fFA4wpB3WloMEvCDaUvvH1LZlBXTNlwi9KtcwD4tDxkkBt4tQczKLGpQ/nF/W9n 8YDWk3IIc1sd0bkZqoau2Q== -----END CERTIFICATE----- Stage SSHSomething
read more

Variables in Jenkins Pipelins

The power that the bash shell affords is hard describe and its familiarity makes the bash shell my go to for almost everything. But I’m continuing on the process of JP (Jenkins Pipelines). With that end, I need to have some variables defined at the beginning of the run and used throughout the entire job. Sometimes these variables will be defined in Groovy. Example 1 def var1 = 'hello world' node('master'){ stage('HW1'){ echo var1 } } output:
read more

Jenkins Pipeline round 1…with examples

Recently started to take them more seriously to see how much work it would be to take my current work flow and augment their power. Most of my jobs are bash scripts that make Jenkins a glorified cron job. Previously Jenkins was very rudimentary, e.g. I just recently started using Jenkins plug-ins for config injection and secret obfuscation. Now I’m trying to take those newly learned processes and add a whole new DSL on top.
read more