Skip to content

Instantly share code, notes, and snippets.

View jovemfelix's full-sized avatar

RENATO ALVES FELIX jovemfelix

View GitHub Profile
@jovemfelix
jovemfelix / openshift-sample-maven-pipeline.yaml
Last active October 23, 2019 14:57
Jenkins Pipeline Demo with Java
apiVersion: v1
kind: Template
metadata:
name: maven-pipeline
parameters:
- name: APP_NAME
description: The name assigned to all of the application objects defined in this template.
displayName: Application Name
required: true
value: openshift-jee-sample
@jovemfelix
jovemfelix / patch-openshift-enviroment-variable.sh
Created October 23, 2019 20:42
example of handling environment variables using oc patch
## SET variable with the name of dc that you want to change
PROJETO=xxxx
# If you need a replacement a suggest you remove and them add
### to remove you can do this
oc set env dc/${PROJETO} KUBERNETES_NAMESPACE-
## add the deployment config with new item
oc patch dc/${PROJETO} --type=json --patch '
GITLAB_TOKEN='nuXXPQyGMmCNwWnsVlm3'
GITLAB_BASE_URL='https://www.example.com.br/repo'
## <YOUR-NAMESPACE>%2F<YOUR-PROJECT-NAME> --> %2F is / url-encoded
GITLAB_PROJECT_NAME='codigo%2Fmoodle-php'
# get project by name
PROJECT_ID=$(curl -XGET -H "Content-Type: application/json" \
-H "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
${GITLAB_BASE_URL}/api/v4/projects/${GITLAB_PROJECT_NAME} | jq '.id')
@jovemfelix
jovemfelix / manage-role-strategy-of-jenkins-using--rest-api.sh
Last active March 5, 2025 16:27
How to Manage and Assign Roles of Jenkins using CURL
# variables - credentials info
USERNAME='my-username'
PASSWORD='my-clear-password'
USER_PASS="${USERNAME}:${PASSWORD}"
# variables - jenkins project and roles
TYPE='projectRoles'
## example of jenkins permission required to execute the Jenkins Job
PERMISSIONIDS='hudson.model.Item.Read,hudson.model.Item.Build'
ROLENAME='my-rolename'
@jovemfelix
jovemfelix / manage-role-strategy-of-jenkins-using--rest-api.md
Last active September 12, 2022 08:40
How to Manage and Assign Roles of Jenkins using CURL

Variables

# credentials info
USERNAME='my-username'
PASSWORD='my-clear-password'
USER_PASS="${USERNAME}:${PASSWORD}"
# associate variable to a personal file location (here use a personal file location like roger-admin)
export KUBECONFIG=$PWD/my-kubeconfig-admin
# create the unique/personal local file
touch $KUBECONFIG
# then make login as usual
oc login <host> -u <username> -p <pass>
# teste it
@jovemfelix
jovemfelix / echos.groovy
Created October 8, 2020 19:49
jenkins echo with stage variable if defined
#!/usr/bin/env groovy
def echos(def s ){
def stage = "[${env.STAGE_NAME}]"
if (stage == "[null]") {
stage = ""
}
println "${stage}${s}"
}
@jovemfelix
jovemfelix / setObjectLabels.groovy
Created October 14, 2020 14:54
set openshift label to object type
/**
* @param args.APP_NAME
* @param args.APP_TYPE
* @param args.ENVIRONMENT
* @param args.OCP_KIND
*/
private void setObjectLabels(Map args) {
echo "[setObjectLabels][init] args: ${args}"
openshift.raw("label", "${args.OCP_KIND}", "${args.APP_NAME}", "app=${args.APP_NAME}", "--overwrite")
openshift.raw("label", "${args.OCP_KIND}", "${args.APP_NAME}", "imagem=${args.APP_TYPE}", "--overwrite")
def OPS_GROUP = 'test-grup-devops'
def userInput = input(id: 'proceed_prd',
message: "Deploy em Produção? Permitido apenas para '${OPS_GROUP}'",
submitter: "${OPS_GROUP}",
parameters: [string(defaultValue: '1',
description: 'Número de instâncias de containers a ser provisionado',
name: 'containers'),
booleanParam(defaultValue: true,
description: 'Confirma se deve realizar deployment neste ambiente. Limpar caso queira evitar deploy neste ambiente.',
@jovemfelix
jovemfelix / waitDeploy.groovy
Created October 19, 2020 15:04
Wait for Openshift Deploy
def waitDeploy(Map args) {
echos "[waitDeploy]: args ${args}"
if (!args.SLEEP) {
args.SLEEP = 10
}
if (!args.TIMEOUT) {
args.TIMEOUT = 10
}
openshift.withCluster() {
openshift.withProject("${args.OCP_NAMESPACE}") {