Jenkins

Jenkins JOB_NAME 가져오기

thxxyj 2024. 5. 14. 10:11
728x90

ex. http://my-jenkins-url/job/CT/job/SmokeTest 인 경우,

 

1. Jenkins environment variable

  • $JOB_NAME : CT/SmokeTest
  • $JOB_BASE_NAME : SmokeTest

https://stackoverflow.com/a/75226828

 

 

2. BUILD_URL에서 추출 (regex)

def myJobName = ''
def mybuildUrl = 'http://my-jenkins-url/job/CT/job/SmokeTest'
def matcher = mybuildUrl =~ '.*/job/([^/]+)/job/([^/]+)/.*'
if (matcher) {
	myJobName = matcher[0][1] + "/" + matcher[0][2]
}

 

 

728x90