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
pipeline { | |
agent any | |
stages { | |
stage('Hello') { | |
steps { | |
script { | |
docker.image("bitnami/kubectl:latest").inside("--userns=host --entrypoint=") { | |
sh 'kubectl config view' | |
} |
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
# Test docker config is setup after running entrypoint.sh | |
@test "check docker config file is present" { | |
config=$(docker run --rm $image /bin/sh -c '/bin/ls -1 /root/.docker/config.json | grep config.json') | |
if [[ ! -z "$config" ]]then | |
return 0 | |
fi | |
return 1 | |
} |
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
import jenkins.model.Jenkins | |
import hudson.model.ListView | |
def jenkins = Jenkins.getInstance() | |
def view = jenkins.getView("My View") | |
def jobs = view.getItems() | |
jobs.each { job -> | |
view.renameJob(job, "New Job Name") | |
view.getColumn("Job Name").setCell(job, "New Job Name") |
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
import jenkins.model.Jenkins | |
import hudson.model.* | |
Jenkins jenkins = Jenkins.getInstance() | |
def allJobs = jenkins.getAllItems() | |
def cmsJobs = allJobs.findAll { job -> job.name.contains("cms") } | |
println "Job Name| Disabled| Last Build Time" | |
cmsJobs.each { job -> |
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
import jenkins.model.* | |
import org.jenkinsci.plugins.workflow.job.WorkflowJob | |
import hudson.plugins.git.GitSCM | |
def gitUrl = 'https://github.com/foo/bar.git' | |
def jenkins = Jenkins.getInstance() | |
def pipelineJobs = jenkins.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob.class) |
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
import os | |
import requests | |
import json | |
# Set the GitLab API token and URL | |
GITLAB_API_TOKEN = 'YOUR_GITLAB_API_TOKEN' | |
GITLAB_API_URL = 'https://gitlab.com/api/v4' | |
# Get the absolute path of the cloned repository | |
repo_path = os.path.abspath('/path/to/cloned/repo') |
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
import tarfile | |
import gzip | |
import os | |
def tar_gzip_directory(directory_path, output_path): | |
""" | |
Creates a GZIP-compressed TAR archive of the specified directory. | |
:param directory_path: The path to the directory to be archived. | |
:param output_path: The path to the output file to be created. |
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
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: my-pod | |
spec: | |
containers: | |
- name: git | |
image: alpine/git:2.36.3 | |
command: | |
- sh |
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
import requests | |
import os | |
# Set the GitLab API endpoint and the registry project ID | |
api_endpoint = "https://gitlab.com/api/v4" | |
registry_project_id = "my-registry-project-id" | |
# Set the GitLab access token (must have read access to the registry project) | |
access_token = os.environ.get("GITLAB_ACCESS_TOKEN") |
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
import os | |
import subprocess | |
# Set environment variables | |
os.environ["CI_JOB_TOKEN"] = "YOUR_CI_JOB_TOKEN" | |
# Define the GitLab Terraform module registry host and module path | |
registry_host = "https://gitlab.com" | |
module_namespace = "your-namespace" | |
module_name = "your-module" |