Last active
March 25, 2023 03:01
-
-
Save parjun8840/8f4aaf0fc5081cb345d2b4513f539330 to your computer and use it in GitHub Desktop.
basic_pipeline_env_credentials
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
def friends_name = ["TOM", "JACk", "HARRY"] | |
pipeline{ | |
agent { | |
kubernetes { | |
yaml ''' | |
apiVersion: v1 | |
kind: Pod | |
spec: | |
containers: | |
- name: kubectl-image | |
image: alpine/k8s:1.24.12 | |
command: | |
- cat | |
tty: true | |
''' | |
} | |
} | |
environment { | |
db_prod = "prod_mysql_prod" | |
db_stg = "prod_mysql_stg" | |
SOME_SECRET = credentials("some_secret") | |
} | |
stages { | |
stage ("Build"){ | |
steps{ | |
container('kubectl-image'){ | |
script { | |
def name = "parjun8840" | |
def hobbies = ['cricket', 'badminton', 'teaching'] | |
env.name_build = name | |
if (name == "parjun8840") { | |
println("Hi $name") | |
} | |
else{ | |
println("Hello $name") | |
} | |
if ("$env.db_prod" == "prod_mysql_prod"){ | |
println("PROD DB is: $env.db_prod") | |
} | |
if ("$env.db_stg" == "prod_mysql_stg"){ | |
println("STG DB is: $env.db_stg") | |
} | |
for (int i = 0; i < hobbies.size(); ++i) { | |
echo "Nice hobby: ${hobbies[i]}" | |
} | |
sleep 2 //Comes from workflow basic step plugin | |
echo "SOME SOME_SECRET is: $env.SOME_SECRET" | |
echo "SOME SOME_SECRET_USR is: $env.SOME_SECRET_USR" | |
echo "SOME SOME_SECRET_PSW is: $env.SOME_SECRET_PSW" | |
echo "Current Build number is: $BUILD_ID" | |
echo "Friends name are: $friends_name" | |
echo "end of script" | |
} | |
} | |
} | |
} | |
stage ("Test"){ | |
steps{ | |
container('kubectl-image'){ | |
echo "Environment from Build stage: $env.name_build" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment