Skip to content

Instantly share code, notes, and snippets.

View paulogesualdo's full-sized avatar

Paulo Gesualdo paulogesualdo

View GitHub Profile
@paulogesualdo
paulogesualdo / inception.groovy
Created March 10, 2023 18:40
To pass a function as a parameter on Jenkins (Groovy)
def commonFunction () {
echo "Hello inception"
}
def commonFunctionAsVariable = this.&commonFunction
def callFunction(functionAsVariable) {
functionAsVariable()
}
@paulogesualdo
paulogesualdo / logonAsAService.txt
Last active March 16, 2023 20:07
Logon as a service
FOR %F IN ("%SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package~*.mum") DO (DISM /Online /NoRestart /Add-Package:"%F")
FOR %F IN ("%SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~*.mum") DO (DISM /Online /NoRestart /Add-Package:"%F")
@paulogesualdo
paulogesualdo / Jenkinsfile
Created January 10, 2023 20:51
Pipeline script to store in a variable the value of a shell command (Jenkinsfile)
def archive_name
pipeline {
agent any
stages {
stage('copy') {
steps {
script {
archive_name = sh ( script: "ssh 192.168.64.15 ls /opt/app",
@paulogesualdo
paulogesualdo / Jenkinsfile
Created January 9, 2023 22:40
Pipeline script to request manual approval to proceed the pipeline (Jenkinsfile)
pipeline {
agent any
stages {
stage('Step One') {
steps {
sh 'echo "Hello from step one"'
}
}
stage('Manual approval') {
@paulogesualdo
paulogesualdo / Jenkinsfile
Created January 9, 2023 22:11
Pipeline script to trigger two other pipelines from one pipeline (Jenkinsfile)
pipeline {
agent any
stages {
stage('Call Pipeline One') {
steps {
build job: 'pipeline-one'
}
}
stage('Call Pipeline Two') {
@paulogesualdo
paulogesualdo / Jenkinsfile
Last active January 10, 2023 22:28
Pipeline script for Jenkins to transfer files between two servers
pipeline {
agent any
stages {
stage("copy") {
steps {
// to copy files from first-server to second-server
sh "scp 192.168.64.15:/opt/app-name/outbox/test.txt 192.168.64.14:/opt/app-name/inbox"
}
}
@paulogesualdo
paulogesualdo / Jenkinsfile
Created January 9, 2023 21:03
Pipeline script for Jenkins use with a Node.js project hosted at the File System (Jenkinsfile)
pipeline {
agent any
stages {
stage('install and test') {
steps {
// the script is multi-line because if the instructions where in independent steps there are errors of command not found with nvm and npm
sh '''
# nvm install
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
@paulogesualdo
paulogesualdo / codedeploy-agent-install.sh
Last active December 30, 2022 18:03
Shell script to install the AWS CodeDeploy agent on an Amazon Linux 2 EC2 instance na região us-east-1
#!/bin/bash
sudo yum update
sudo yum install ruby -y
sudo yum install wget
CODEDEPLOY_BIN="/opt/codedeploy-agent/bin/codedeploy-agent"
$CODEDEPLOY_BIN stop
sudo yum erase codedeploy-agent -y
cd /home/ec2-user
#Executar comando semelhante ao abaixo, mudar a região caso necessário:
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
@paulogesualdo
paulogesualdo / docker-install.sh
Last active December 30, 2022 17:37
Shell script to install Docker and Docker Compose on an Amazon Linux 2 instance
#!/bin/bash
sudo yum update -y
sudo yum install docker -y
sudo systemctl start docker.service
sudo chmod 666 /var/run/docker.sock
sudo yum install python3-pip
sudo pip3 install docker-compose
docker ps
docker info
@paulogesualdo
paulogesualdo / docker-info-output.txt
Last active December 30, 2022 18:04
Docker info output example
Client:
Context: desktop-linux
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.9.1)
compose: Docker Compose (Docker Inc., v2.13.0)
dev: Docker Dev Environments (Docker Inc., v0.0.5)
extension: Manages Docker extensions (Docker Inc., v0.2.16)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.22.0)