Skip to content

Commit

Permalink
Merge pull request #17 from tobania/https
Browse files Browse the repository at this point in the history
fix: Do credential magic to support https
  • Loading branch information
NoUseFreak authored Feb 27, 2024
2 parents 1d54518 + 22d57c6 commit 8cb1396
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/io/stenic/jpipe/plugin/ConventionalCommitPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,22 @@ class ConventionalCommitPlugin extends Plugin {
return true
}

script.sshagent(credentials: [script.scm.getUserRemoteConfigs()[0].getCredentialsId()]) {
script.sh "git tag ${version}"
script.sh "git push origin ${version}"
script.sh "git tag ${version}"
def gitUrl = script.scm.getUserRemoteConfigs()[0].getUrl()
def credentialsId = script.scm.getUserRemoteConfigs()[0].getCredentialsId()
if (gitUrl.startsWith('https') {
script.withCredentials([script.usernamePassword(
credentialsId: credentialsId,
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD'
)]) {
def gitUrlWithCreds = gitUrl.replaceFirst(/https:\/\//, "https://${env.GIT_USERNAME}:${env.GIT_PASSWORD}@")
script.sh "git push ${gitUrlWithCreds} ${version}"
}
} else {
script.sshagent(credentials: [credentialsId]) {
script.sh "git push origin ${version}"
}
}

return true
Expand Down

0 comments on commit 8cb1396

Please sign in to comment.