Skip to content

Instantly share code, notes, and snippets.

View ssbostan's full-sized avatar

Saeid Bostandoust ssbostan

  • London
View GitHub Profile
@ssbostan
ssbostan / pipeline.sh
Created April 22, 2020 07:50
Write CI/CD Pipeline with Bash
#!/bin/bash
# Copyright (c) 2020, Saeid Bostandoust
# ssbostan@linuxmail.org
# https://b9t.ir
# All rights reserved.
PIPELINE_PROJECT_NAME="YOUR-PROJECT-NAME"
if [[ ! -d "./$PIPELINE_PROJECT_NAME" ]]; then
git clone YOUR-GIT-ADDRESS
fi
@ssbostan
ssbostan / backup.sh
Created May 3, 2020 15:52
Create a backup and Delete old backups
#!/bin/bash
tar -zcf /backups/backup-$(date +%Y%m%d).tar.gz --absolute-names /data
rm -f /backups/backup-$(date -d 'now - 7 days' +%Y%m%d).tar.gz
@ssbostan
ssbostan / intro1.pipeline
Created July 18, 2021 09:46
Jenkins pipeline syntax reference
pipeline {
agent any
stages {
stage("Build") {
steps {
echo "Build stage."
}
}
stage("Test") {
steps {
@ssbostan
ssbostan / intro2.pipeline
Created July 18, 2021 09:47
Jenkins pipeline syntax reference
pipeline {
agent none
stages {
stage("Build") {
agent any
steps {
echo "Build stage."
}
}
}
@ssbostan
ssbostan / intro3.pipeline
Created July 18, 2021 10:00
Jenkins pipeline syntax reference
pipeline {
agent {
label "linux"
}
stages {
stage("Build") {
steps {
echo "Build stage."
}
}
@ssbostan
ssbostan / intro4.pipeline
Created July 18, 2021 10:07
Jenkins pipeline syntax reference
pipeline {
agent {
docker "alpine"
}
stages {
stage("Build") {
steps {
sh "hostname"
}
}
@ssbostan
ssbostan / intro5.pipeline
Created July 18, 2021 10:19
Jenkins pipeline syntax reference
pipeline {
agent {
dockerfile true
}
stages {
stage("Build") {
steps {
sh "hostname"
}
}
@ssbostan
ssbostan / env1.jenkins
Created August 1, 2021 10:25
Jenkins pipeline syntax reference
pipeline {
agent any
environment {
SAMPLE_GLOBAL_ENV_VAR = "Test global ENV variables."
}
stages {
stage("Build") {
environment {
SAMPLE_STAGE_ENV_VAR = "Test stage ENV variables."
}
@ssbostan
ssbostan / env2.jenkins
Last active September 7, 2021 10:51
Jenkins pipeline syntax reference
pipeline {
agent any
environment {
SAMPLE_ENV = credentials("simple-secret-text")
}
stages {
stage("Release") {
steps {
// Do not use " for command methods like sh, bat, powershell, pwsh, etc.
// Use ' to avoid groovy interpolation and command injection vulnerabilities.
@ssbostan
ssbostan / env3.jenkins
Last active September 7, 2021 10:51
Jenkins pipeline syntax reference
pipeline {
agent any
environment {
MYUSERPASS = credentials("test-user-pass")
}
stages {
stage("Test") {
steps {
// Do not use " for command methods like sh, bat, powershell, pwsh, etc.
// Use ' to avoid groovy interpolation and command injection vulnerabilities.