Calling function from another groovy file into Jenkins pipeline

Jenkinsfile

pipeline
{
    agent any
    stages
    {
        stage('build')
        {
            steps
            {
                script
                {
                    //first.groovy path might change as per your need
                    def var1 = load "first.groovy"
                    var1.build("php build")
                }
                sh '''
                echo "build"
                '''
            }
        }
        
        stage('deploy')
        {
            steps
            {
                script
                {
                    def var2 = load "first.groovy"
                    var2.build("php deploy")
                }
                    sh '''
                    echo "deploy"
                    '''
            }
        }
        
        
    }
}

first.groovy

def build(String arg1) {
        sh """
        echo "from build function : ${arg1}"
        """
}

def deploy(String arg2) {
        sh """
        echo "from deploy function : ${arg2}"
        """
}

return this

Output:

Running on Jenkins in /var/lib/jenkins/workspace/initedit/ss
[Pipeline] {
[Pipeline] stage
[Pipeline] { (build)
[Pipeline] script
[Pipeline] {
[Pipeline] load
[Pipeline] { (first.groovy)
[Pipeline] }
[Pipeline] // load
[Pipeline] sh
+ echo 'from build function : php build'
from build function : php build
[Pipeline] }
[Pipeline] // script
[Pipeline] sh
+ echo build
build
...........

Run cs 1.6 server with docker

  1. Install docker – https://docs.docker.com/install/linux/docker-ce/debian/
docker run -d -p 26900:26900/udp -p 27020:27020/udp -p 27015:27015/udp -p 27015:27015 -e ADMIN_STEAM=0:1:1234566 --name cs cs16ds/server:latest

github : https://github.com/JimTouz/counter-strike-docker

For interactive docker terminal change the entry point:

docker run it --entrypoint /bin/bash --name cs cs16ds/server:latest

install cs16 in linux ubuntu16

mkdir cs
cd cs
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar xvfz steamcmd_linux.tar.gz
sudo apt-get install lib32gcc1
./steamcmd.sh
login anonymous
force_install_dir ./cs16/
app_update 90 validate (run till you get fully installed message)
exit
cd cs16server​
./hlds_run -console -game cstrike +port 27015 +de_dust2 +maxplayers 32 -pingboost 1

Install addons:
amxmodx dproto metamod

https://wiki.alliedmods.net/Installing_AMX_Mod_X_Manually

Note: path for metamod.so should not be absolute.

http://www.amxmod.net/doc/amxmod_2010.1/en/amxusers.html


Prometheus monitoring tool

# Install Prometheus https://prometheus.io/download/

wget https://github.com/prometheus/prometheus/releases/download/v2.13.1/prometheus-2.13.1.linux-amd64.tar.gz

tar -xf prometheus-2.13.1.linux-amd64.tar.gz

mv prometheus-2.13.1.linux-amd64 /etc/prometheus

nano /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/prometheus \
–config.file /etc/prometheus/prometheus.yml \
–storage.tsdb.path /var/lib/prometheus/ \
–web.console.templates=/etc/prometheus/consoles \
–web.console.libraries=/etc/prometheus/console_libraries

[Install]
WantedBy=multi-user.target

cd /etc/prometheus
cp prometheus promtool tsdb /usr/local/bin/

systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus

Prometheus port : 9090

# Install node_exporter

wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz

tar -xf node_exporter-0.18.1.linux-amd64.tar.gz

cp node_exporter-0.18.1.linux-amd64 /node_exporter /usr/local/bin/

nano /etc/systemd/system/node_exporter.service

[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl start node_exporter
systemctl status node_exporter
systemctl enable node_exporter

# add node_exporter to prometheus.yml

systemctl restart prometheus

Gitlab backup and restore

Note : gitlab should be same version.

Manual backup:

/etc/gitlab/gitlab-secrets.json

/etc/gitlab/gitlab.rb

 

Generate backup:

gitlab-rake gitlab:backup:create

 

Restore backup:

You have run sudo gitlab-ctl reconfigure at least once.
GitLab is running. If not, start it using sudo gitlab-ctl start.

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

gitlab-rake gitlab:backup:restore BACKUP=335565885_2019_05_20.6

restore /etc/gitlab/gitlab-secrets.json and /etc/gitlab/gitlab.rb