@Library("jenkins-library@main")

import com.logicalclocks.jenkins.k8s.ImageBuilder


node("local") {
    stage('Clone repository') {
      checkout scm
    }

    stage('Build and push image(s)') {
    version = readFile "${env.WORKSPACE}/tests/KUBE_IMAGE_VERSION"
      withEnv(["VERSION=${version.trim()}"]) {
        withCredentials([string(credentialsId: '990f5312-cd08-48ec-baf8-3b27ff551204', variable: 'GITHUB_API_TOKEN')]) {
          sh 'git config --file gitconfig "url.https://x-access-token:$GITHUB_API_TOKEN@github.com/.insteadOf" https://github.com/'
        }

        def builder = new ImageBuilder(this)
        m = readFile "${env.WORKSPACE}/tests/build-manifest.json"
        builder.run(m)
     }
    }
}