library(
identifier: 'jenkins-shared-library@master',
retriever: modernSCM(
[
$class: 'GitSCMSource',
remote: 'https://github.com/dhanarab/jenkins-pipeline-library.git'
]
)
)
bitbucketCredentialsHttps = "bitbucket-build-extend-https"
bitbucketCredentialsSsh = "bitbucket-build-extend-ssh"
repoName = "extend-sdk-mcp-server"
repoBranchName = "update"
slackActivityChannel = "#activity-extend-engineering"
sdkSpecGitHash = null
sdkSpecPath = null
sdkCodegenPath = null
mcpServerPath = null
pipeline {
agent {
label "extend-builder-batch && linux-amd64"
}
stages {
stage("Prepare") {
steps {
script {
sdkCodegenPath = "${env.WORKSPACE}/justice-codegen-modular-sdk"
sdkSpecPath = "${env.WORKSPACE}/justice-codegen-sdk-spec"
mcpServerPath = "${env.WORKSPACE}"
sh "rm -rf ${sdkCodegenPath}"
sh "rm -rf ${sdkSpecPath}"
sshagent(credentials: [bitbucketCredentialsSsh]) {
sh "git clone --depth 1 git@bitbucket.org:accelbyte/justice-codegen-modular-sdk.git ${sdkCodegenPath}"
sh "git clone --depth 50 git@bitbucket.org:accelbyte/justice-codegen-sdk-spec.git ${sdkSpecPath}"
}
dir(sdkCodegenPath) {
sh "make build-linux PLATFORM=amd64"
}
dir(".justice-codegen-sdk-spec") {
script {
sdkSpecGitHash = git.getCommitHashShort()
}
}
}
}
}
stage("Update") {
steps {
script {
sh "git branch ${repoBranchName}"
sh "git checkout ${repoBranchName}"
sh "rm -rfv config/*"
sh "mkdir -p config/csharp"
sh "mkdir -p config/go"
sh "mkdir -p config/java"
sh "mkdir -p config/python"
dir("${sdkCodegenPath}/templates/mcp-commands") {
sh "make generate_snippets CODEGEN_PATH=${sdkCodegenPath}/accelbyte-codegen-linux_amd64 SPEC_PATH=${sdkSpecPath}/spec/stage_extend-sdk OUT_PATH=${mcpServerPath}/config/csharp LANGUAGE=csharp"
sh "make generate_snippets CODEGEN_PATH=${sdkCodegenPath}/accelbyte-codegen-linux_amd64 SPEC_PATH=${sdkSpecPath}/spec/stage_extend-sdk OUT_PATH=${mcpServerPath}/config/go LANGUAGE=go"
sh "make generate_snippets CODEGEN_PATH=${sdkCodegenPath}/accelbyte-codegen-linux_amd64 SPEC_PATH=${sdkSpecPath}/spec/stage_extend-sdk OUT_PATH=${mcpServerPath}/config/java LANGUAGE=java"
sh "make generate_snippets CODEGEN_PATH=${sdkCodegenPath}/accelbyte-codegen-linux_amd64 SPEC_PATH=${sdkSpecPath}/spec/stage_extend-sdk OUT_PATH=${mcpServerPath}/config/python LANGUAGE=python"
}
sh "git add config/."
if (sh(script: "git status --porcelain config/. | grep '.*'", returnStatus: true) == 0) {
sh 'make build' // Test build before committing changes
sh "git commit -m 'chore(config): update justice-codegen-sdk-spec ${sdkSpecGitHash}'"
sshagent(credentials: [bitbucketCredentialsSsh]) {
sh "git push origin +${repoBranchName}:${repoBranchName}"
}
repoCommitHash = git.getCommitHash()
repoCommitHashShort = git.getCommitHashShort()
repoCommitMessage = git.getCommitMessage()
message = """
:white_check_mark: <${env.BUILD_URL}|${env.JOB_NAME}-${env.BUILD_NUMBER}> *config update successful*
|*${repoName}:*
|<https://bitbucket.org/accelbyte/${repoName}/commits/${repoCommitHash}|${repoBranchName} ${repoCommitHashShort}>
|${repoCommitMessage}
|""".stripMargin()
slackSend(channel: "${slackActivityChannel}", color: '#36B37E', message: message)
}
}
}
}
}
post {
failure {
script {
message = """
:no_entry: <${env.BUILD_URL}|${env.JOB_NAME}-${env.BUILD_NUMBER}> *config update failed*
|""".stripMargin()
slackSend(channel: "${slackActivityChannel}", color: '#FF0000', message: message)
}
}
}
}