Skip to content

Instantly share code, notes, and snippets.

View marcosborges's full-sized avatar

Marcos Borges marcosborges

View GitHub Profile
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import jenkins.model.Jenkins;
import com.cloudbees.hudson.plugins.folder.Folder
import com.cloudbees.plugins.credentials.Credentials
import com.cloudbees.plugins.credentials.CredentialsProvider
def folderName = "folder/subfolder/subsubfolder"
def credentialId = "credential-id"
def folder = Jenkins.getInstance().getAllItems(Folder.class).find({ it -> it.getFullName().contains(folderName) })
fdisk -l
# Expansão do disco
1. Liste os discos e encontre o novo disco
```
lsblk
```
import jenkins.model.Jenkins
import hudson.model.Job
import jenkins.model.BuildDiscarderProperty
import hudson.tasks.LogRotator
def total = 0
// LogRotator ( daysToKeep, numToKeep, artifactDaysToKeep, artifactNumToKeep)
// daysToKeep: If not -1, history is only kept up to this days.
// numToKeep: If not -1, only this number of build logs are kept.
pipeline {
agent any
options {
preserveStashes(buildCount: 10)
buildDiscarder(logRotator(numToKeepStr:'10'))
}
<?php declare(strict_types=1);
require_once 'vendor/autoload.php';
use Siler\Swoole;
use Siler\GraphQL;
use Siler\Http\Response;
// Enable CORS for GraphiQL
import org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException
import hudson.util.Secret
import com.cloudbees.plugins.credentials.CredentialsScope
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl
import com.cloudbees.plugins.credentials.domains.Domain
node {
try{
withCredentials([
import jenkins.model.Jenkins
import jenkins.plugins.git.GitSCMSource
import jenkins.plugins.git.traits.BranchDiscoveryTrait
import org.jenkinsci.plugins.workflow.libs.GlobalLibraries
import org.jenkinsci.plugins.workflow.libs.LibraryConfiguration
import org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever
def sharedLibraryName = "mySharedLibName"
def repository = "[email protected]:[OWNER]/[REPO].git"
def total = 0
def findInScript = ""
def findInName = ""
Jenkins.getInstance().getAllItems().each {
if(it?.getDescriptor().getDisplayName() == "Pipeline") {
if (
it.getDefinition()?.getScript()?.contains(findInScript) &&
it.getFullName().contains(findInName)
){
println "${it.getFullName()}"
Jenkins.getInstance().getAllItems().each {
if(it?.getDescriptor().getDisplayName() == "Pipeline") {
if (
it.getFullName().contains('JOB_NAME')
){
println "Deleting... ${it.getFullName()}"
it.delete()
}
}
}