Created
October 23, 2020 19:50
-
-
Save jovemfelix/95b49e33a93b7d6ee5680d9a7e74bfe0 to your computer and use it in GitHub Desktop.
Openshift using jenkins pipeline -create or apply YML
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
| /** | |
| * @param args.FOLDER_YML | |
| * @param args.OCP_KIND < configmap, secret > | |
| * @return | |
| */ | |
| def manageYML(Map args) { | |
| def configMapList = findFiles(glob: "${args.FOLDER_YML}") | |
| echos "[${args.OCP_KIND}][found]: ${configMapList}" | |
| configMapList.each { f -> | |
| def strings = "${f}".split('/') | |
| def filename = strings[strings.length - 1] | |
| def fileNameWithoutExtension = filename.take(filename.lastIndexOf('.')) | |
| if (openshift.selector(args.OCP_KIND, "${fileNameWithoutExtension}").exists()) { | |
| echos "[${args.OCP_KIND}][update]: ${fileNameWithoutExtension}" | |
| echos "[${args.OCP_KIND}][cat]: ${fileNameWithoutExtension}" | |
| sh returnStdout: true, script: "cat ${f}" | |
| openshift.apply('-f', "${f}") | |
| } else { | |
| echos "[${args.OCP_KIND}][create]: ${fileNameWithoutExtension}" | |
| openshift.create('-f', "${f}", '--save-config', '--validate') | |
| } | |
| } | |
| } | |
| //// | |
| manageYML([ | |
| OCP_KIND : 'configmap', | |
| FOLDER_YML: "${args.APP_DEFAULT_NAME}/${args.APP_AMBIENTE}/configmap/*.yml" | |
| ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment