feat(pipeline): add credentials support for semantic release in SemanticReleasingExecutor

Signed-off-by: 孙振宇 <>
This commit is contained in:
孙振宇 2025-02-08 10:20:52 +08:00
parent 80dd57433c
commit d8f04dda6d
2 changed files with 13 additions and 10 deletions

View File

@ -19,11 +19,13 @@ class SemanticReleasingExecutor {
this.config = 'com/freeleaps/devops/builtins/semantic-release/releaserc.json'
}
def release() {
def release(credentialsId) {
steps.log.warn("SemanticReleasingExecutor", "Configuration file customization is not supported yet, using builtin release rules as fallback")
steps.log.info("SemanticReleasingExecutor", "Releasing with config: ${config}")
steps.dir(steps.env.workroot) {
steps.withCredentials(credentialsId: credentialsId, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME') {
steps.env.GIT_CREDENTIALS = "${steps.env.GIT_USERNAME}:${steps.env.GIT_PASSWORD}"
steps.writeFile file: 'releaserc.json', text: steps.libraryResource(config)
steps.log.info("SemanticReleasingExecutor", "Installing semantic-release requirements...")
steps.sh "apt-get -y update && apt-get install -y --no-install-recommends git apt-transport-https ca-certificates curl wget gnupg"
@ -35,3 +37,4 @@ class SemanticReleasingExecutor {
}
}
}
}

View File

@ -265,7 +265,7 @@ def generateComponentStages(component, configurations) {
def sourceFetcher = new SourceFetcher(this)
sourceFetcher.fetch(configurations)
def semanticReleasingExecutor = new SemanticReleasingExecutor(this, env.workroot + "/" + component.root + "/")
def semanticReleasingExecutor = new SemanticReleasingExecutor(this, env.workroot)
semanticReleasingExecutor.release()
}
}