puzzle / jenkins-pipeline-shared-libraries

Shared functionality for Jenkins Pipeline Groovy scripts.
GNU General Public License v3.0
10 stars 13 forks source link

Test Quay utility class #59

Open chrira opened 6 months ago

chrira commented 6 months ago

Write tests in the GitHub repo as soon as the test framework is decided.

import com.puzzleitc.jenkins.Quay

pipeline {
    agent any
    environment {
        CRED = 'quay-token'
        REGISTRY_URL = 'https://registry.ch'
        ORG = 'org'
        REPOSITORY = 'backend'
        TAG='2.6.6'
        NEW_TAG='3.0.0'
    }
    stages {
        stage('tags') {
            steps {
                script {
                    Quay quay = new Quay(this, env.CRED, env.REGISTRY_URL)

                    // get sha of image referenced by the tag
                    def sha = quay.getTagManifest(env.ORG, env.REPOSITORY, env.TAG)
                    println "SHA: " + sha

                    // add new tag to image
                    quay.addTag(env.ORG, env.REPOSITORY, sha, env.NEW_TAG)
                }
            }
        }
    }
}