github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/Jenkinsfile-stage (about)

     1  pipeline {
     2      agent {
     3              kubernetes {
     4        defaultContainer 'jnlp'
     5        yaml """
     6  apiVersion: v1
     7  kind: Pod
     8  metadata:
     9  labels:
    10    name: agentes
    11  spec:
    12    # Use service account that can deploy to all namespaces
    13    serviceAccountName: jenkins
    14    containers:
    15    - name: brudbuntu
    16      image: bam.brud.local:6000/brudtech/brudbuntu:v0.0.1
    17      command:
    18      - cat
    19      tty: true
    20      volumeMounts:
    21      - mountPath: /var/run/docker.sock
    22        name: docker-sock
    23    volumes:
    24      - name: docker-sock
    25        hostPath:
    26          path: /var/run/docker.sock
    27  """
    28    }
    29      }
    30      environment {
    31          DB_USERNAME = credentials('db-un-voting-db')
    32          DB_PASSWORD = credentials('db-userp-voting')
    33          IPFS_KEY = credentials('db-ipfskey-voting')
    34          IPFS_SECRET = credentials('ipfs-secrets-voting')
    35          FLOW_URL = credentials('db-flowurl-voting')
    36          tag = sh(returnStdout: true, script: "git rev-parse --short=10 HEAD").trim()
    37          longtag = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
    38      }
    39  
    40  //--------------------------------------------------------------------------------------------------------------------------------
    41  // STAGE
    42  //--------------------------------------------------------------------------------------------------------------------------------
    43      stages {       
    44  
    45  //--------------------------------------------------------------------------------------------------------------------------------
    46  // BUILD IMAGE
    47  //--------------------------------------------------------------------------------------------------------------------------------       
    48  
    49          stage('BUILD IMAGE') {
    50          steps {
    51                  container('brudbuntu') {
    52                  script {
    53                      echo "building the docker image for Voting Tool..."
    54                      sh 'docker build . -t bam.brud.local:6000/brudtech/flow-voting-tool-backend:${tag}-vt'
    55                      sh 'docker push bam.brud.local:6000/brudtech/flow-voting-tool-backend:${tag}-vt'  
    56                    }
    57                  }
    58              }
    59          }
    60  //--------------------------------------------------------------------------------------------------------------------------------
    61  // CREATE STAGE ENVIRONMENT
    62  //--------------------------------------------------------------------------------------------------------------------------------
    63          stage('BUILDING BACKEND IMAGES') {
    64              steps {
    65                  container('brudbuntu') {
    66                  script {
    67                        sh 'chmod +x test_image.sh'
    68                        sh "sh test_image.sh ${tag}"
    69                                          }
    70                                      }
    71                                  }
    72                          }
    73  
    74  
    75      }
    76  }