From 7bcdfceb32d37b501facba48bc530929391e943d Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 1 Feb 2023 09:17:31 +0000 Subject: [PATCH] environment test --- Jenkinsfile | 53 +++++++++++++---------------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8ef0fa5..81dc795 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,47 +1,20 @@ -/* pipeline 변수 설정 */ +podTemplate(containers: [ + containerTemplate( + name: 'jnlp', + image: 'jenkins/inbound-agent:latest' + ) + ]) { -def label = "worker-${UUID.randomUUID().toString()}" -def DATE = new Date(); - -podTemplate( - label: label, - containers: [ - containerTemplate(name: 'gradle', image: 'gradle:7.6-jdk11', command: 'cat', ttyEnabled: true), - ], - volumes: [ - hostPathVolume(mountPath: '/home/gradle/.gradle', hostPath: '/tmp/jenkins/.gradle'), - ] -) - -{ - node(label) { - def myRepo = checkout scm - def gitCommit = myRepo.GIT_COMMIT - def gitBranch = myRepo.GIT_BRANCH - def shortGitCommit = "${gitCommit[0..10]}" - def previousGitCommit = sh(script: "git rev-parse ${gitCommit}~", returnStdout: true) - - stage('Test') { - try { - container('gradle') { - sh """ - pwd - echo "GIT_BRANCH=${gitBranch}" >> /etc/environment - echo "GIT_COMMIT=${gitCommit}" >> /etc/environment - gradle test - """ + node(POD_LABEL) { + stage('Get a project') { + container('jnlp') { + stage('Shell Execution') { + sh ''' + echo "Hello! I am executing shell" + ''' } } - catch (exc) { - println "Failed to test - ${currentBuild.fullDisplayName}" - throw(exc) - } } - stage('Build') { - container('gradle') { - sh "gradle build" - } - } } } \ No newline at end of file