Last active
May 7, 2022 07:51
-
-
Save archmangler/f8d040e641f377d99f86fc584ffaf3db to your computer and use it in GitHub Desktop.
Jenkins CasC: Snippets and Resources
This file contains 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
# References | |
- Examples: https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos | |
``` | |
pipelineJob("ragnarok") { | |
definition { | |
cps { | |
sandbox(true) | |
script(""" | |
pipeline { | |
agent any | |
parameters { | |
string(name: 'MFA_TOKEN', defaultValue: 'null', description: 'Enter MFA Token') | |
} | |
stages { | |
stage("Testing") { | |
steps { | |
sh '''#!/bin/bash | |
set +x | |
git clone "https://.....git" | |
cd trading-system-load-engine/ | |
source env.sh \${MFA_TOKEN} | |
pwd | |
ls -l | |
echo \$HOME | |
cd ~/ | |
pwd | |
''' | |
} | |
} | |
stage("Deploying") { | |
steps { | |
sh '''#!/bin/bash | |
for i in `seq 1 20`;do echo "\$i - waiting to get ready ..." - \$(sleep 1);done | |
''' | |
} | |
} | |
stage("Configuring") { | |
steps { | |
sh '''#!/bin/bash | |
kubectl get pods -o wide -n ragnarok | |
kubectl get services -n ragnarok | |
for i in `seq 1 20`;do echo "\$i - waiting to get ready ..." - \$(sleep 1);done | |
''' | |
} | |
} | |
stage("Decommissioning") { | |
steps { | |
sh '''#!/bin/bash | |
for i in `seq 1 30`;do echo "\$i - running stuff ..." - \$(sleep 5);done | |
for i in `seq 1 10`;do echo "\$i - waiting for shut down ..." - \$(sleep 1);done | |
kubectl get pods -n ragnarok | |
''' | |
} | |
} | |
} | |
} | |
""") | |
} | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment