import groovy.json.JsonBuilder if (params.configPipeline in [null, true]){ echo "INFO: Start config job" configPipeline() addHtmlBadge html: 'Config', id: '' return } timestamps{ node('k8s-agent-run'){ def dockerConfigPath = "${env.WORKSPACE}" stage("cleaning"){ cleanWs() } stage("pull"){ withCredentials([usernamePassword(credentialsId: CRED_ARTIFACTORY, passwordVariable: 'nexusPass', usernameVariable: 'nexusUser')]) { dir('app') { checkout scm echo "jenkins env = ${env.JOB_NAME}-${env.BUILD_NUMBER}" sh "docker build -t build-${env.JOB_NAME}-${env.BUILD_NUMBER} . --progress plain --no-cache" sh "docker ps -a" //sh "docker images" //sh "docker cp build-${env.JOB_NAME}-${env.BUILD_NUMBER}:/tmp/publish/App01.dll ." //sh "docker cp 200d14fc32d1:/tmp/publish/App01.dll ." def result=sh script:"docker run -t -d --rm --entrypoint= build-${env.JOB_NAME}-${env.BUILD_NUMBER}:latest sleep 360", returnStdout: true echo "${result}" sh "docker cp ${result.trim()}:/tmp/publish ." sh "ls -la" sh "tar cfz distr.tar.gz publish" sh "tar cfz source.tar.gz Program.cs App01.csproj" sh "ls -la" sh """ curl -u "${nexusUser}:${nexusPass}" \ -X PUT \ -H "Content-Type: application/octet-stream" \ --data-binary @distr.tar.gz \ "https://pvw.tn.tngrp.ru/ssd/tools/arr-ci/repository/tnt_maven/ru/tnt/etnt/helloworld/1.0.0-${env.BUILD_NUMBER}/helloworld-1.0.0-${env.BUILD_NUMBER}.tar.gz" curl -u "${nexusUser}:${nexusPass}" \ -X PUT \ -H "Content-Type: application/octet-stream" \ --data-binary @source.tar.gz \ "https://pvw.tn.tngrp.ru/ssd/tools/arr-ci/repository/tnt_maven/ru/tnt/etnt/helloworld-sources/1.0.0-${env.BUILD_NUMBER}/helloworld-sources-1.0.0-${env.BUILD_NUMBER}.tar.gz" """ sh "docker rmi --force build-${env.JOB_NAME}-${env.BUILD_NUMBER}" } sh "ls -la" } } } } def configPipeline() { echo "Config it!" properties([ parameters([ booleanParam( defaultValue: false, description: "Конфигурация pipeline", name: "configPipeline"), string( defaultValue: params.CRED_ARTIFACTORY, description: "Кред для аутентификации в Artifactory", trim: true, name: "CRED_ARTIFACTORY") ]) ]) }