Skip to content

Instantly share code, notes, and snippets.

View marcelaraujo's full-sized avatar

Marcel Araujo marcelaraujo

View GitHub Profile
@marcelaraujo
marcelaraujo / jenkins-list-credentials.groovy
Last active September 9, 2020 09:19
List Jenkins Credentials
import com.cloudbees.plugins.credentials.CredentialsNameProvider
import com.cloudbees.plugins.credentials.Credentials
import com.cloudbees.plugins.credentials.CredentialsProvider
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey
import org.jenkinsci.plugins.plaincredentials.StringCredentials
import org.jenkinsci.plugins.plaincredentials.FileCredentials
String checksum( String input ) {
FROM php:7.3-alpine
# This image is ready to build projects using technologies:
# - PHP7 (with Lumen)
# - Angular v8
# Check stack details in: https://confluence.agile.corp.edp.pt/display/TNG/PHP7
ENV COMPOSER_VERSION=1.9.3 \
COMPOSER_CACHE_DIR=/tmp/.composer/cache \
#!/bin/bash
mkdir -p ssl
cat << EOF > ssl/req.cnf
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
[req_distinguished_name]
[ v3_req ]
#!/bin/bash
mkdir -p ssl
cat << EOF > ssl/req.cnf
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
[req_distinguished_name]
@marcelaraujo
marcelaraujo / addCredentials.groovy
Created March 20, 2020 10:11
Add Jenkins Credentials
import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey
import com.cloudbees.plugins.credentials.CredentialsScope
import com.cloudbees.plugins.credentials.SystemCredentialsProvider
import com.cloudbees.plugins.credentials.common.StandardCredentials
import com.cloudbees.plugins.credentials.domain.Domain
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl
import hudson.util.Secret
import org.apache.commons.fileupload.FileItem
import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl
@marcelaraujo
marcelaraujo / readm.md
Created March 20, 2020 10:09
Curl as LDAP client

Use curl as an LDAP client

curl "ldap://localhost:1389/dc=example,dc=com?homephone?sub?cn=*amar" \

     -u "cn=directory manager"
Enter host password for user 'cn=directory manager':
DN: uid=mathieu,ou=People,dc=example,dc=com
    homephone: +1 225 216 5900
import com.cloudbees.plugins.credentials.*;
import com.cloudbees.plugins.credentials.domains.Domain;
import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl;
def secret = '''Hi
there,
only
test'''
def secretBytes = SecretBytes.fromBytes(secret.getBytes())
If you want to forward a non-k8s-managed port and have permission to stand up a new pod, you can run the alpine/socat image and port-forward to that:
kubectl run --restart=Never --image=alpine/socat TEMP_POD_NAME -- -d -d tcp-listen:PORT,fork,reuseaddr tcp-connect:HOSTNAME:PORT
kubectl wait --for=condition=Ready pod/TEMP_POD_NAME
kubectl port-forward pod/TEMP_POD_NAME LOCAL_PORT:PORT
Don't forget to bring the pod down once you're done.
kubectl delete pod/TEMP_POD_NAME --grace-period 1 --wait=false