node {
    def app

   /*stage('Initialize'){
        def dockerHome = tool 'myDocker'
        env.PATH = "${dockerHome}/bin:${env.PATH}"
    }*/

    stage('Clone repository') {
        /* Let's make sure we have the repository cloned to our workspace */
        checkout scm
    }

    stage('Build image') {
        /* This builds the actual image; synonymous to
         * docker build on the command line */
        

         app = docker.build("hochzeit:latest")
        
    }

    stage('Test image') {
        /* Ideally, we would run a test framework against our image.
         * For this example, we're using a Volkswagen-type approach ;-) */
        app.inside {
            sh 'echo "Tests passed"'
        }
    }

    stage('Snyk Test') {
        /* This stage runs Snyk to test the image for vulnerabilities.
         * Make sure you have the Snyk plugin installed in Jenkins. */
        snykSecurity test: 'hochzeit:latest', failOnError: true, failOnIssues: true, snykInstallation: 'snyk@latest', snykTokenId: "SNYK API"
    }

    stage('Push image') {
        /* Finally, we'll push the image with two tags:
         * First, the incremental build number from Jenkins
         * Second, the 'latest' tag.
         * Pushing multiple tags is cheap, as all the layers are reused. */
            docker.withRegistry('https://container.kornblum.dev', 'container-kornblum-dev') {
                app.push("${env.BUILD_NUMBER}")
                app.push("latest")
            }
    }

    stage('webhook deployment portainer') {
       sh "curl -X POST -k https://portainer.kornblum.dev/api/stacks/webhooks/8da9930d-966f-4696-8087-302e2ce139ba"
    }
}