aboutsummaryrefslogtreecommitdiff
path: root/Jenkinsfile
blob: 22dd78e384b1af78bdda1d14429814ea4c46bbbc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
pipeline {
  agent {
    docker {
      image 'quay.io/buildah/stable'
      args '--privileged=true'
    }
  }
  options  { parallelsAlwaysFailFast() }
  triggers { cron(cron_string) }
  environment {
    PROJECT        = 'nvim'
    IMAGE_NAME     = "docker.io/chn2guevara/$PROJECT"
  }
  stages {
    stage('Prepare') {
      steps {
        sh 'dnf install git -y'
        script {
          env.TAG_NAME = sh(
            returnStdout: true,
            script: 'git name-rev --name-only --tags HEAD | sed \'s/^undefined$//\'').trim()
        }
      }
    }
    stage('Manifest') {
      steps { sh "buildah manifest create $PROJECT" }
    }
    stage('Build') {
      parallel {
        stage('arm64/v8 stable') {
          steps {
            sh"""
              buildah build --pull --platform linux/arm64/v8 --network host \
                --tag $IMAGE_NAME:stable --build-arg NEOVIM_VERSION=stable \
                --manifest $PROJECT .
            """
          }
        }
        stage('amd64 stable') {
          steps {
            sh"""
              buildah build --pull --platform linux/amd64 --network host \
                --tag $IMAGE_NAME:stable --build-arg NEOVIM_VERSION=stable \
                --manifest $PROJECT .
            """
          }
        }
        stage('arm64/v8 nightly') {
          steps {
            sh"""
              buildah build --pull --platform linux/arm64/v8 --network host \
                --tag $IMAGE_NAME:nightly --build-arg NEOVIM_VERSION=nightly \
                --manifest $PROJECT .
            """
          }
        }
        stage('amd64 nightly') {
          steps {
            sh"""
              buildah build --pull --platform linux/amd64 --network host \
                --tag $IMAGE_NAME:nightly --build-arg NEOVIM_VERSION=nightly \
                --manifest $PROJECT .
            """
          }
        }
      }
    }
    stage('docker.io login') {
      when  { branch 'master' }
      steps {
        withCredentials([string(
          credentialsId: 'dockerhub-personal',
          variable: 'CREDENTIALS')
        ]) {
          sh '''#!/bin/bash
              IFS=" " read -r username password <<<"$CREDENTIALS"
              buildah login \
              --username "$username" \
              --password-stdin <<< "$password" docker.io
            '''
        }
      }
    }
    stage('Push') {
      when  { branch 'master' }
      parallel {
        stage('stable') {
          steps { sh "buildah manifest push --all $PROJECT docker://$IMAGE_NAME:stable" }
        }
        stage('nightly') {
          steps { sh "buildah manifest push --all $PROJECT docker://$IMAGE_NAME:nightly" }
        }
      }
    }
  }
}