Skip to content

Instantly share code, notes, and snippets.

View Constantin07's full-sized avatar
🏠
Working from home

Constantin Bugneac Constantin07

🏠
Working from home
View GitHub Profile
@a-shevtsov
a-shevtsov / Jenkinsfile
Created October 6, 2018 01:08
Running Docker container in Jenkins scripted pipeline
node {
// First parameter represents additional docker run options, second parameter is arguments passed to the image
// docker run [OPTIONS|<First parameter>] IMAGE [COMMAND] [ARG...|<Second parameter>]
docker.image('mesosphere/aws-cli').withRun('--entrypoint /bin/sh', '') {
stage('Build') {
sh 'aws --version'
}
}
}
@soloradish
soloradish / vault_logrotate
Created September 12, 2018 02:25
logrotate setting file for HashiCorp's Vault audit file
# Change the path below to your own audit log path.
/var/log/vault/audit.log {
rotate 30
daily
# Do not execute rotate if the log file is empty.
notifempty
missingok
compress
# Set compress on next rotate cycl to prevent entry loss when performing compression.
delaycompress
@ivan-pinatti
ivan-pinatti / jenkins-add-ssh-keypair-with-password-credential.groovy
Last active June 21, 2023 11:46
Jenkins - Add SSH keypair with password credential via groovy script - #jenkins #groovy #ssh #credential
#!groovy
// imports
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.Domain
import com.cloudbees.plugins.credentials.impl.*
import hudson.util.Secret
import java.nio.file.Files
@odavid
odavid / Jenkins-delete-lockable-resources
Created September 14, 2017 15:55
A short script to delete free locks from the lockable resources plugin
def manager = org.jenkins.plugins.lockableresources.LockableResourcesManager.get()
def resources = manager.getResources().findAll{
!it.locked
}
resources.each{
manager.getResources().remove(it)
}
manager.save()
@peterjenkins1
peterjenkins1 / harden-jenkins.groovy
Last active August 12, 2020 18:31
Harden Jenkins with groovy
// Harden Jenkins and remove all the nagging warnings in the web interface
import jenkins.model.Jenkins
import jenkins.security.s2m.*
Jenkins jenkins = Jenkins.getInstance()
// Disable remoting
jenkins.getDescriptor("jenkins.CLI").get().setEnabled(false)
// Enable Agent to master security subsystem
@dongfg
dongfg / Jenkinsfile
Created July 3, 2017 05:38
jenkins pipeline send message to DingTalk
node {
try {
stage('common build stage'){
echo 'build ...'
}
currentBuild.result = "SUCCESS"
} catch(e) {
currentBuild.result = "FAIL"
}
@butla
butla / wait_for_tcp_port.py
Last active December 8, 2022 19:52
Waiting for a TCP port to start accepting connections (Python >=3.6)
"""
MIT License
Copyright (c) 2017 Michał Bultrowicz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@artburkart
artburkart / codedeploy_agent_install.yml
Last active August 13, 2018 21:33
Ansible scripts to install & run CodeDeploy not as unprivileged user on Ubuntu
---
- name: Update apt cache
apt: update_cache=yes
- name: Install Ruby
apt: pkg=ruby2.0 state=present
- block:
- name: Get CodeDeploy version
set_fact:
@tomnomnom
tomnomnom / once-per-jenkins-slave.groovy
Created May 16, 2016 12:47
Run a command once on each Jenkins slave using the CloudBees Workflow / Jenkins Pipeline plugin
// The ArrayList of slaves is not serializable, so fetching them should be marked as @NonCPS so that
// no attempt is made to serialize and save the local state of the function. See here for details:
// https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md#serializing-local-variables
@NonCPS
def getSlaves() {
def slaves = []
hudson.model.Hudson.instance.slaves.each {
slaves << it.name
}
return slaves
@johnbuhay
johnbuhay / setup-users.groovy
Created January 21, 2016 01:15
jenkins init.groovy.d script for configuring users
import jenkins.*
import hudson.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
import hudson.model.*
import jenkins.model.*
import hudson.security.*