Software and Systems How-To's, Tutorials, Demos, Notes

Using CICD Pipeline Part 2

Objectives:

Assumptions

Setup Gogs

Configure the Deployment Config

and change to

   source:
    type: Git
    git:
      uri: 'http://gogs-gogs.10.1.2.2.nip.io/bcorpus/todoAPIjs.git'
      ref: master
    sourceSecret:
      name: gogs-secret

Configure GitHook

#!/bin/bash
while read oldrev newrev ref
do
    if [[ $ref =~ refs/tags ]];
    then
        echo "Master ref received.  Deploying master branch to production..."
        TAG=`echo $ref|sed 's#refs/tags/\(.*\)#\1#g'`
        curl -v -k --user <userid>:<api token> -G "https://jenkins-todo-dev.10.1.2.2.nip.io/job/todo-dev-todo-pipeline/buildWithParameters" -d token=secret -d commit=$newrev -d tag=$TAG
    else
        echo "Ref $ref successfully received.  Doing nothing: only the master branch may be deployed on this server."
    fi
done

Configure Jenkins

Test the setup

You have now configured automated build upon pushing to Git!