Skip to content

Commit

Permalink
fix jenkins job for snapshot version deployment (apache#7338)
Browse files Browse the repository at this point in the history
  • Loading branch information
htynkn authored Mar 9, 2021
1 parent 96e44f6 commit 3ae0409
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pipeline {
stage('Duplicate deploy check') {
steps {
script {
def deployedCommitId = sh(returnStdout: true, script: "curl --silent https://builds.apache.org/job/Apache%20Dubbo/job/${env.JOB_BASE_NAME}/lastSuccessfulBuild/artifact/DEPLOY_COMMIT_ID || true").trim()
def deployedCommitId = sh(returnStdout: true, script: "curl --silent https://ci-builds.apache.org/job/Dubbo/job/${env.JOB_BASE_NAME}/lastSuccessfulBuild/artifact/DEPLOY_COMMIT_ID || true").trim()
env.DEPLOYED_COMMIT_ID = deployedCommitId
def commitId = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
env.COMMIT_ID = commitId
Expand All @@ -65,22 +65,26 @@ pipeline {
def commitId = env.COMMIT_ID
println "Current commit id: $commitId"

def commitStatusJson = sh(script: "curl --silent https://api.github.com/repos/apache/dubbo/commits/$commitId/status", returnStdout: true).trim()
println "Commit status: \r\n$commitStatusJson"
def commitStatusJson = sh(script: "curl --silent https://api.github.com/repos/apache/dubbo/actions/runs", returnStdout: true).trim()

def jsonSlurper = new JsonSlurper()
def jsonObject = jsonSlurper.parseText(commitStatusJson)

def status = jsonObject.state

println "Current commit status is $status"

if (status == "success") {
env.STATUS_CHECK = "true"
println "Continue to deploy snapshot"
} else {
env.STATUS_CHECK = "false"
println "Current commit status not allow to deploy snapshot"
def runs = jsonObject.workflow_runs

for (def run in runs) {
if (run.workflow_id == 5030221 && run.head_sha == commitId &&
run.event == "push" && run.head_branch == "master") {
println "Find github action for current commit: $run"
if (run.status == "completed" && run.conclusion == "success") {
env.STATUS_CHECK = "true"
println "CI status is success for commitId:$commitId, continue to deploy"
} else {
env.STATUS_CHECK = "false"
println "CI status is not success for commitId:$commitId"
}
break;
}
}
}
}
Expand Down

0 comments on commit 3ae0409

Please sign in to comment.