Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Jenkins file trigger issue due to var substitution #28

Merged
Merged
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
8 changes: 7 additions & 1 deletion jenkins/publish-snapshot.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ pipeline {
stage('Publish to Sonatype Snapshots Repo') {
steps {
script {
println('Start Trigger')
def ref_final = "${GIT_REFERENCE}"
def ref_url = "${REPO_URL}/commit/${GIT_REFERENCE}"
if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) {
ref_final = ${ref}
ref_final = "${ref}"
ref_url = "${REPO_URL}/releases/tag/${ref}"
println("Triggered by GitHub: ${ref_url}")

Expand All @@ -55,6 +56,11 @@ pipeline {
currentBuild.description = """User/Timer: <a href="${ref_url}">${ref_url}</a>"""
}

if (ref_final == null || ref_final == '') {
currentBuild.result = 'ABORTED'
error("Missing git reference.")
}

// https://docs.gradle.org/current/samples/sample_publishing_credentials.html
// https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties
withCredentials([usernamePassword(credentialsId: 'jenkins-sonatype-creds', usernameVariable: 'ORG_GRADLE_PROJECT_snapshotRepoUsername', passwordVariable: 'ORG_GRADLE_PROJECT_snapshotRepoPassword')]) {
Expand Down