Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pipeline {
agent {
label 'llrgrhgtrig.in2p3.fr'
}

environment {
LABEL_TEST='test'
LABEL_REF='ref'
Expand All @@ -25,6 +26,7 @@ pipeline {
echo "log_Jenkins does not exist."
fi
echo '==> Set environment variables'
echo '== Start testing webhooks =='
'''
script{
String s = env.JOB_NAME
Expand Down Expand Up @@ -200,6 +202,7 @@ pipeline {
stage('Install CMSSW Test release'){
steps {
sh '''
echo "Testing"
./HGCTPGValidation/scripts/installCMSSW_global.sh $SCRAM_ARCH $REF_RELEASE $REMOTE $BASE_REMOTE $CHANGE_BRANCH $CHANGE_TARGET ${LABEL_TEST}
echo ' '
'''
Expand Down Expand Up @@ -301,6 +304,55 @@ pipeline {
println( "Validation of the validation: Set the original name of CHANGE_BRANCH => " + env.CHANGE_BRANCH )
}

// Comments
def commentCauses = currentBuild.getBuildCauses("com.adobe.jenkins.github_pr_comment_build.GitHubPullRequestCommentCause")
if (commentCauses) {
for (def commentCause : commentCauses) {
echo("""Comment Author: ${commentCause.commentAuthor}, Body: "${commentCause.commentBody}" (${commentCause.commentUrl})""")
}
} else {
echo("Build was not started by a PR comment")
}

// Labels
def labelCauses = currentBuild.getBuildCauses("com.adobe.jenkins.github_pr_comment_build.GitHubPullRequestLabelCause")
if (labelCauses) {
for (def labelCause : labelCauses) {
echo("""Label Author: ${labelCause.labellingAuthor}, Label: "${labelCause.label}" (${labelCause.labelUrl})""")
}
} else {
echo("Build was not started by a PR label")
}

// Reviews
def reviewCauses = currentBuild.getBuildCauses("com.adobe.jenkins.github_pr_comment_build.GitHubPullRequestReviewCause")
if (reviewCauses) {
for (def reviewCause : reviewCauses) {
echo("""Review Author: ${reviewCause.reviewAuthor} (${reviewCause.pullRequestUrl})""")
}
} else {
echo("Build was not started by a PR review")
}

// Updates
def updateCauses = currentBuild.getBuildCauses("com.adobe.jenkins.github_pr_comment_build.GitHubPullRequestUpdateCause")
if (updateCauses) {
for (def updateCause : updateCauses) {
echo("""Update Author: ${updateCause.updateAuthor} (${updateCause.pullRequestUrl})""")
}
} else {
echo("Build was not started by a PR update")
}

// Detecting whether a build was started by the trigger in a script
if(currentBuild.upstreamBuilds){
print("Parent")
print(currentBuild.upstreamBuilds[0].getBuildCauses()[0].userId)
} else {
print("No parent")
print(currentBuild.getBuildCauses()[0].userId)
}

def message = ""
if (currentBuild.result == 'SUCCESS') {
message = "The validation checks have passed." + "<br>" + "The comparison histograms are available [here](${env.WEBPAGES_VAL}list_config.php?pr=/PR$CHANGE_ID)"
Expand Down
4 changes: 2 additions & 2 deletions scripts/write_toGitHub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ set +x exec >> log_Jenkins;
module use /opt/exp_soft/vo.llr.in2p3.fr/modulefiles_el7/;
module purge; module load python/3.9.9;
# For the organization hgc-tpg
python /data/jenkins/workspace/create_token_hgc-tpg.py > /tmp/github_token
#python /data/jenkins/workspace/create_token_hgc-tpg.py > /tmp/github_token
# For the organization test-org-hgctpg
#python /data/jenkins/workspace/create_token.py > /tmp/github_token
python /data/jenkins/workspace/create_token.py > /tmp/github_token

# Compose the url to be used for printing the message in the GitHub PR thread
# In the string "url" replace "pull" with "issues" and add at the end "comments"
Expand Down