Configure your local development environment.
Assumes deploying to minikube
using the VirtualBox driver
helm v3 CLI installed
envsubst installed
kubectl installed
kubernetes-chart git repository cloned
./run-local.sh local
# Copy Paste this
export POD_NAME=$(kubectl get pods --namespace jenkins -l "app.kubernetes.io/component=jenkins-master" -l "app.kubernetes.io/instance=jenkins" -o jsonpath="{.items[0].metadata.name}")
# Check if Jenkins is running. Make sure you are not connected to VPN
kubectl get pods -n jenkins -w
# Once running. Port forward the localhost to Jenkins Pod
kubectl --namespace jenkins port-forward $POD_NAME 8080:8080
Default User name and password is part of the tmpl file. Credentials are admin/admin
In K8s plugin. If Pod is not creating. Check your POD TEMPLATE SYNTAX or If you add hostPath in the POD template and container has no access to the host folder.
AWS ECR is usually a private repo
Download the inside the Minikube
# Use Minikube as the docker ENV
eval $(minikube -p minikube docker-env)
# Assume the admin role that has access to ECR
source assume main 123456
# Login to ECR
aws ecr get-login-password --region ap-southeast-1 | docker login --username AWS --password-stdin 929981421241.dkr.ecr.ap-southeast-1.amazonaws.com
# Pull the needed image. This will copy the image in Minikube, not in local
docker pull 929981421241.dkr.ecr.ap-southeast-1.amazonaws.com/diginex-cli:latest
# Disconnect the Local to Minikube
eval $(minikube -p minikube docker-env -u)
Create a Test Pipeline Job 01Pipeline
Go to Main Configuration and Load Library Implicitly!
Add the following codes.
Review the Jenkins Logs.
@Library('jenkins-global-libraries') _
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: shell
image: alpine/git:v2.26.2
command:
- sleep
args:
- infinity
'''
defaultContainer 'shell'
}
}
stages {
stage('Test') {
steps {
sh 'hostname'
sh 'env'
// ADD CODE HERE THAT CALLS LOCAL LIB
}
}
}
}
Create a Test Pipeline Job
Download the inside the Minikube
Adding Jenkins Shared Libraries in Local
No need to git checkin to test jenkins libraries.
You need a Token for "admin "user config page and generate token
ANS: Go to main Library and check the LOAD IMPLICITY
ANS: Generate new token for admin user