Jenkins

Deleting old builds

cd /var/jenkins_home/jobs/
du -h -d 1
ls | grep -E '[0-9]' | xargs rm -rf

Access secrets from the script console

import com.cloudbees.plugins.credentials.CredentialsProvider
import com.cloudbees.plugins.credentials.domains.Domain
import jenkins.model.Jenkins
import hudson.util.Secret
import org.apache.commons.io.IOUtils

def credentialsId = "<credentials_id>"

def credentials = CredentialsProvider.lookupCredentials(
    com.cloudbees.plugins.credentials.common.StandardCredentials.class,
    Jenkins.instance,
    null,
    null
).find { it.id == credentialsId }
def inputStream = credentials.content
def content = IOUtils.toString(inputStream, "UTF-8")
println(content)