서버를 다시 시작하지 않고 Jenkins에서 막을 수없는 좀비 작업을 중지하는 방법은 무엇입니까?
Jenkins 서버에 3 일 동안 실행 된 작업이 있지만 아무것도하지 않습니다. 모서리에있는 작은 X를 클릭해도 아무 것도 수행되지 않으며 콘솔 출력 로그에도 아무 것도 표시되지 않습니다. 빌드 서버를 확인했는데 실제로 작업이 전혀 실행되지 않는 것 같습니다.
젠킨스에게 파일이나 잠금 등을 편집하여 작업이 "완료"되었다고 알리는 방법이 있습니까? 많은 작업이 있으므로 서버를 다시 시작하고 싶지 않습니다.
"Jenkins 관리"> "스크립트 콘솔"로 이동하여 서버에서 스크립트를 실행하여 중단 스레드를 중단하십시오.
모든 라이브 스레드를 가져 와서 Thread.getAllStackTraces()
걸려있는 스레드를 중단 할 수 있습니다 .
Thread.getAllStackTraces().keySet().each() {
t -> if (t.getName()=="YOUR THREAD NAME" ) { t.interrupt(); }
}
최신 정보:
스레드를 사용하는 위의 솔루션은 최신 Jenkins 버전에서 작동하지 않을 수 있습니다. 고정 된 파이프 라인을 중단하려면 대신 alexandru-bantiuc에 의한 이 솔루션을 참조하여 다음 을 실행하십시오.
Jenkins.instance.getItemByFullName("JobName")
.getBuildByNumber(JobNumber)
.finish(
hudson.model.Result.ABORTED,
new java.io.IOException("Aborting build")
);
나는 또한 같은 문제가 있었고 Jenkins Console을 통해 수정했습니다.
"Jenkins 관리"> "스크립트 콘솔"로 이동하여 스크립트를 실행하십시오.
Jenkins .instance.getItemByFullName("JobName")
.getBuildByNumber(JobNumber)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
JobName과 JobNumber를 지정하면됩니다.
이 작업에 모니터링 플러그인 을 사용 합니다 . 플러그인 설치 후
- Jenkins 관리> Hudson / Jenkins 마스터 모니터링으로 이동하십시오.
- 오른쪽의 작은 파란색 링크 인 스레드 세부 사항을 펼치십시오.
중단 된 작업 명 검색
스레드 이름은 다음과 같이 시작됩니다
Executor #2 for master : executing <your-job-name> #<build-number>
원하는 작업이있는 행 표의 오른쪽에있는 빨간색, 둥근 버튼을 클릭하십시오.
"스크립트 콘솔"로 중지 할 수없는 빌드가 발생했습니다. 마지막으로 다음 단계로 문제를 해결했습니다.
ssh onto the jenkins server
cd to .jenkins/jobs/<job-name>/builds/
rm -rf <build-number>
restart jenkins
경우에 당신은 가지고 Multibranch 파이프 라인 -job을 (당신은 젠킨스 - 관리자입니다)에서의 사용 젠킨스 스크립트 콘솔 이 스크립트 :
Jenkins.instance
.getItemByFullName("<JOB NAME>")
.getBranch("<BRANCH NAME>")
.getBuildByNumber(<BUILD NUMBER>)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
에서 https://issues.jenkins-ci.org/browse/JENKINS-43020
작업의 전체 이름 (경로)이 확실하지 않은 경우 다음 스 니펫을 사용하여 모든 항목의 전체 이름을 나열 할 수 있습니다.
Jenkins.instance.getAllItems(AbstractItem.class).each {
println(it.fullName)
};
에서 https://support.cloudbees.com/hc/en-us/articles/226941767-Groovy-to-list-all-jobs
첫 번째 제안 된 솔루션은 매우 가깝습니다. interrupt () 대신 stop ()을 사용하면 그루비 시스템 스크립트에서 끝없이 실행되는 런 어웨이 스레드도 죽입니다. 이것은 작업을 위해 실행되는 모든 빌드를 종료합니다. 코드는 다음과 같습니다.
Thread.getAllStackTraces().keySet().each() {
if (it.name.contains('YOUR JOBNAME')) {
println "Stopping $it.name"
it.stop()
}
}
중지 할 수없는 파이프 라인 작업이있는 경우 다음을 시도하십시오.
- 빌드 진행률 표시 줄 옆에있는 빨간색 X를 클릭하여 작업을 중단하십시오.
- 빌드에서 "일시 중지 / 다시 시작"을 클릭하여 일시 중지
- "일시 정지 / 재개"를 다시 클릭하여 빌드를 다시 시작하십시오.
Jenkins는 작업을 종료하고 빌드를 중지해야 함을 인식합니다.
이러한 경우 빌드 타임 아웃 플러그인 이 유용 할 수 있습니다. 너무 오래 걸리면 작업이 자동으로 종료됩니다.
대답하기에는 너무 늦었지만 일부 사람들의 도움이 필요합니다.
- 모니터링 플러그인을 설치하십시오. ( http://wiki.jenkins-ci.org/display/JENKINS/Monitoring )
- jenkinsUrl / 모니터링 / 노드로 이동
- 하단의 스레드 섹션으로 이동
- 마스터 왼쪽의 세부 정보 버튼을 클릭하십시오
- 사용자 시간 (ms)별로 정렬
- 그런 다음 스레드의 이름을 보면 빌드의 이름과 번호가 표시됩니다
- 죽여
이미지를 게시 할 정도로 평판이 좋지 않습니다.
그것이 도움이되기를 바랍니다.
가장 큰 대답 은 거의 효과가 있었지만 한 가지 큰 문제가 있습니다. 특히 Jenkins가 제대로 시작되지 않아서 좀비 작업이 너무 많아서 (~ 100) 매우 많았습니다. 따라서 작업 이름과 빌드 번호를 수동으로 찾고 모든 좀비 작업과 수동으로 죽일 수 없었습니다. 좀비 작업을 자동으로 찾아서 죽인 방법은 다음과 같습니다.
Jenkins.instance.getItemByFullName(multibranchPipelineProjectName).getItems().each { repository->
repository.getItems().each { branch->
branch.builds.each { build->
if (build.getResult().equals(null)) {
build.doKill()
}
}
}
}
이 스크립트는 모든 작업의 모든 빌드를 반복 getResult().equals(null)
하며 작업 완료 여부를 결정하는 데 사용 됩니다. 대기열에 있지만 아직 시작되지 않은 빌드는 반복되지 않으며 (빌드가 포함되지 않기 때문에 job.builds
) 이미 완료된 빌드는 null
for 이외의 것을 반환 합니다 build.getResult()
. 합법적으로 실행중인 작업의 빌드 결과 null
도이므로이 작업을 실행하기 전에 종료하지 않으려는 실행중인 작업이 없는지 확인하십시오.
다중 분기 루프는 다중 분기 파이프 라인 프로젝트의 모든 저장소에 대한 모든 분기 / PR을 발견하는 데 주로 필요합니다. 다중 분기 파이프 라인을 사용하지 않는 경우 모든 작업을 다음과 같이 직접 반복 할 수 있습니다 Jenkins.instance.getItems().each
.
Jenkins 소스를 살펴본 결과 작업 중단이 스레드 인터럽트를 통해 수행되는 것처럼 보이기 때문에 수행하려는 작업이 불가능한 것으로 보입니다. 나는 왜 일이 걸려 있는지 모르겠다 ..
편집하다:
막을 수없는 직업에 대한 가능한 이유 :
- Jenkins가 무한 루프에 빠지면 중단 될 수 없습니다.
- Jenkins가 Java VM 내에서 네트워크 또는 파일 I / O를 수행하는 경우 (예 : 긴 파일 복사 또는 SVN 업데이트) 중단 할 수 없습니다.
나는 보통 그런 경우 jenkins-cli를 사용합니다. 페이지에서 jar 파일을 다운로드 할 수 있습니다 http://your-jenkins-host:PORT/cli
. 그런 다음 실행
java -jar jenkins-cli.jar delete-builds name_of_job_to_delete hanging_job_number
보조 정보 :
같은 빌드 범위를 전달할 수도 있습니다 350:400
. 다음을 실행하여 사용 가능한 일반 도움말
java -jar jenkins-cli.jar help
에 delete-builds
의해 컨텍스트 명령 도움말
java -jar jenkins-cli.jar delete-builds
Alexandru Bantiuc의 답변은 빌드를 중단하는 데 효과적 이었지만 내 유언 집행 인은 여전히 바쁘게 나타났습니다. 다음을 사용하여 바쁜 실행기 상태를 지울 수있었습니다.
server_name_pattern = /your-servers-[1-5]/
jenkins.model.Jenkins.instance.getComputers().each { computer ->
if (computer.getName().find(server_name_pattern)) {
println computer.getName()
execList = computer.getExecutors()
for( exec in execList ) {
busyState = exec.isBusy() ? ' busy' : ' idle'
println '--' + exec.getDisplayName() + busyState
if (exec.isBusy()) {
exec.interrupt()
}
}
}
}
지난 반 시간에 같은 문제가 발생했습니다 ...
다중 분기 파이프 라인에서 실행중인 좀비 빌드를 삭제할 수 없습니다. 심지어 서버로 UI를 다시 시작하거나 명령 줄에서 다시 sudo service jenkins restart
실행 해도 실행이 차단되었습니다 ... 빌드를 중지 할 수 없었습니다 ... 항상 다시 시작되었습니다.
사용 된 버전 : Jenkins ver 2.150.2
나는 매우 화가 났지만 ... 빌드의 로그를 볼 때 로그 끝에 무언가 흥미로운 것을 발견했습니다.
빨간색으로 표시된 부분은 "충분한 부분"입니다. 보시다시피 항상 UI에서 빌드를 중단하고 싶었지만 작동하지 않았습니다 ...
그러나 텍스트가있는 하이퍼 링크가 있습니다 Click here to forcibly terminate running steps
... (첫 번째 녹색 링크) 이제 링크를 눌렀습니다 ...) 링크 실행 후 Still paused
다른 링크 Click here to forcibily kill entire build
(두 번째 녹색 링크)와 함께 메시지가 나타났습니다. 이 링크를 누르면 빌드가 마침내 어려웠습니다. 살해 ...
따라서 이것은 특별한 플러그인없이 작동하는 것 같습니다 (멀티 브랜치 파이프 라인 빌드 플러그인 자체 제외).
최근 파이프 라인 작업의 빌드 "X"가 하나의 executor를 며칠 동안 점유 한 노드 / 에이전트를 발견했지만, 빌드 "X"라고 주장하는 작업 페이지는 더 이상 존재하지 않습니다 (10 개의 후속 빌드 (!) 후에 폐기 됨). 파이프 라인 작업에서 구성). 디스크에서 확인 : 빌드 "X"가 실제로 사라졌습니다.
해결책 : 점유 된 실행자가 빌드 "X"를 실행하는 중이라고 잘못보고 한 것이 에이전트 / 노드였습니다. 실행기의 스레드를 중단하면 즉시 스레드가 해제됩니다.
def executor = Jenkins.instance.getNode('NODENAME').computer.executors.find {
it.isBusy() && it.name.contains('JOBNAME')
}
println executor?.name
if (executor?.isBusy()) executor.interrupt()
고려 된 다른 답변들 :
- @cheffe의 답변 : 작동하지 않았습니다 (다음 요점 참조 및 아래 업데이트).
- 답변
Thread.getAllStackTraces()
없음 : 일치하는 스레드가 없습니다. getBuildByNumber()
빌드가 더 이상 존재하지 않았 으므로 @ levente-holló의 답변과 :의 모든 답변이 적용되지 않았습니다!- @ austinfromboston의 대답 : 그것은 내 요구에 가까웠지만 현재 실행중인 다른 빌드를 숨겼을 것입니다.
업데이트 :
비슷한 상황이 발생하여 Executor가 (기존의) 완성 된 파이프 라인 빌드로 며칠 동안 점령되었습니다. 이 코드 스 니펫은 유일한 작동 솔루션이었습니다.
Had this same issue but there was not stack thread. We deleted the job by using this snippet in the Jenkins Console. Replace jobname and buil dnumber with yours.
def jobname = "Main/FolderName/BuildDefinition"
def buildnum = 6
Jenkins.instance.getItemByFullName(jobname).getBuildByNumber(buildnum).delete();
I had many zombi-jobs, so I used the following script:
for(int x = 1000; x < 1813; x = x + 1) {
Jenkins .instance.getItemByFullName("JOBNAME/BRANCH")
.getBuildByNumber(x)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"))
}
If you do not want to use the script console or additional plugins, try these simple solutions as mentioned in https://wiki.jenkins.io/plugins/servlet/mobile?contentId=36603009#content/view/36603009
Pipeline jobs can by stopped by sending an HTTP POST request to URL endpoints of a build.
- BUILD ID URL/stop - aborts a Pipeline.
- BUILD ID URL/term - forcibly terminates a build (should only be used if stop does not work.
- BUILD ID URL/kill - hard kill a pipeline. This is the most destructive way to stop a pipeline and should only be used as a last resort.
Have had the same problem happen to me twice now, the only fix sofa has been to restart the tomcat server and restart the build.
A utility I wrote called jkillthread can be used to stop any thread in any Java process, so long as you can log in to the machine running the service under the same account.
VERY SIMPLE SOLUTION
The reason I was seeing this issue was incorrect http
link on the page instead of https
that should stop the job. All you need to do is to edit onclick
attribute in html page, by following
- Open up a console log of the job (pipeline) that got hang
- Click whatever is available to kill the job (x icon, "Click here to forcibly terminate running steps" etc) to get "Click here to forcibly kill entire build" link visible (it's NOT gonna be clickable at the moment)
- Open the browser's console (use any one of three for chrome: F12; ctrl + shift + i; menu->more tools->developer tools)
- Locate "Click here to forcibly kill entire build" link manually or using "select an element in the page" button of the console
- Double click on
onclick
attribute to edit its value - Append
s
tohttp
to havehttps
- Press enter to submit the changes
- Click "Click here to forcibly kill entire build" link
Using the Script console at https://my-jenkins/script
import hudson.model.Job
import org.jenkinsci.plugins.workflow.job.WorkflowRun
Collection<Job> jobs = Jenkins.instance.getItem('My-Folder').getAllJobs()
for (int i = 0; i < jobs.size(); i++) {
def job = jobs[i]
for (int j = 0; j < job.builds.size(); j++) {
WorkflowRun build = job.builds[j]
if (build.isBuilding()) {
println("Stopping $job ${build.number}")
build.setResult(Result.FAILURE)
}
}
}
You can just copy the job and delete the old one. If it doesn't matter that you lost the old build logs.
Here is how I fixed this issue in version 2.100
with Blue Ocean
- The only plugins I have installed are for bitbucket.
- I only have a single node.
ssh
into my Jenkins box
cd ~/.jenkins
(where I keep jenkins)
cd job/<job_name>/branches/<problem_branch_name>/builds
rm -rf <build_number>
After this, you can optionally change the number in nextBuildNumber
(I did this)
Finally, I restarted jenkins (brew services restart jenkins
) This step will obviously be different depending how you manage and install Jenkins.
Enter the blue-ocean UI. Try to stop the job from there.
'Programming' 카테고리의 다른 글
Virtualenv 명령을 찾을 수 없음 (0) | 2020.06.08 |
---|---|
파이썬 :리스트에서 요소 찾기 (0) | 2020.06.08 |
UILabel sizeToFit가 자동 레이아웃 ios6에서 작동하지 않습니다 (0) | 2020.06.08 |
안드로이드에서 지연을 설정하는 방법? (0) | 2020.06.08 |
ConfigParser의 목록 (0) | 2020.06.08 |