Skip to content

Commit

Permalink
Test update status
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste committed Jun 22, 2023
1 parent 89a0250 commit 5461d26
Showing 1 changed file with 57 additions and 6 deletions.
63 changes: 57 additions & 6 deletions .ci/jenkins/Jenkinsfile.build-image
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('jenkins-pipeline-shared-libraries')_
@Library('jenkins-pipeline-shared-libraries')_

QUAY_REGISTRY = 'quay.io'

Expand Down Expand Up @@ -33,15 +33,19 @@ pipeline {
script {
clean()

sh 'printenv'

setupGithubCommitStatus()

assert getBuildImageName() : 'Please provide `BUILD_IMAGE_NAME` parameter'

currentBuild.displayName = params.DISPLAY_NAME ?: currentBuild.displayName

if (getTargetBranch()) {
echo "Got a target branch ... Trying to merge the source with the target"
echo 'Got a target branch ... Trying to merge the source with the target'
githubscm.checkoutIfExists(getRepoName(), getSourceAuthor(), getSourceBranch(), getTargetAuthor(), getTargetBranch(), true)
} else {
echo "No target branch ... Checking out simply"
echo 'No target branch ... Checking out simply'
checkout(githubscm.resolveRepository(getRepoName(), getSourceAuthor(), getSourceBranch(), false))
}

Expand Down Expand Up @@ -106,6 +110,8 @@ pipeline {
dir('target/image') {
cloud.dockerBuildMultiPlatformImages(getBuiltImageTag(), getImageBuildPlatforms(), shouldDeployImage(), squashMessage)
}

updateGithubCommitStatus()
}
}
}
Expand Down Expand Up @@ -136,8 +142,8 @@ pipeline {
}
try {
cloud.skopeoCopyRegistryImages(cloud.getReducedTag(getDeployImageTag()), getBuiltImageTag(reducedTag), retries)
} catch(err) {
echo "Reduced tag cannot be applied"
} catch (err) {
echo 'Reduced tag cannot be applied'
}
}
}
Expand Down Expand Up @@ -345,4 +351,49 @@ boolean isProdCI() {

String getQuarkusPlatformURL() {
return params.QUARKUS_PLATFORM_URL
}
}

//////////////////////////////////////////////////////////////////////////
// Update commit status

def getRepoURL() {
String url = sh(returnStdout: true, script: 'git config --get remote.origin.url').trim()
echo "Got Repo URL -> ${url}"
return url
}

def getCommitSha() {
String sha = sh(returnStdout: true, script: "git show-ref -s ${getSourceBranch()}").trim()
echo "Got Commit SHA -> ${sha}"
return sha
}

def setupGithubCommitStatus() {
step([
$class: 'GitHubSetCommitStatusBuilder',
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "simple-test"],
statusMessage: [ content : 'Hello' ]
])
}

def updateGithubCommitStatus() {
// workaround https://issues.jenkins-ci.org/browse/JENKINS-38674
repoUrl = getRepoURL()
commitSha = getCommitSha()

step([
$class: 'GitHubCommitStatusSetter',
commitShaSource: [$class: 'ManuallyEnteredShaSource', sha: commitSha],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "simple-test"],
errorHandlers: [[$class: 'ShallowAnyErrorHandler']],
reposSource: [$class: 'ManuallyEnteredRepositorySource', url: repoUrl],
statusResultSource: [
$class: 'ConditionalStatusResultSource',
results: [
[$class: 'BetterThanOrEqualBuildResult', result: 'SUCCESS', state: 'SUCCESS', message: 'anything'],
[$class: 'BetterThanOrEqualBuildResult', result: 'FAILURE', state: 'FAILURE', message: 'anything'],
[$class: 'AnyBuildResult', state: 'FAILURE', message: 'Loophole']
]
]
])
}

0 comments on commit 5461d26

Please sign in to comment.