Jenkins/pipelines/sentry.jenkinsfile

77 lines
2.4 KiB
Plaintext
Raw Normal View History

2020-10-23 10:57:25 +02:00
pipeline {
agent {
docker {
image "getsentry/sentry-cli"
args "--entrypoint="
}
}
environment {
2023-05-03 15:31:18 +02:00
projectDir = "${env.project_name}_${env.BUILD_ID}"
2020-10-23 10:57:25 +02:00
}
stages {
stage("Clone repository") {
steps {
2023-05-03 15:31:18 +02:00
checkout scm:
2020-10-23 10:57:25 +02:00
[
2023-05-03 15:31:18 +02:00
$class: 'GitSCM',
userRemoteConfigs: [[url: env.repository_url, credentialsId: 'jenkins-ssh-mse']],
2020-10-23 10:57:25 +02:00
branches: [[name: env.ref]],
extensions: [
[$class: 'RelativeTargetDirectory', relativeTargetDir: env.projectDir ],
[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: ''],
[$class: 'WipeWorkspace' ]
]
2023-05-03 15:31:18 +02:00
],
changelog: false,
2020-10-23 10:57:25 +02:00
poll: false
}
}
stage('Create sentry release') {
steps {
dir(env.projectDir) {
withCredentials([
string(credentialsId: 'sentry-url', variable: 'SENTRY_URL'),
string(credentialsId: 'sentry-release-auth-token', variable: 'SENTRY_AUTH_TOKEN')
]) {
sh '''
SENTRY_CMD="sentry-cli --auth-token \"${SENTRY_AUTH_TOKEN}\" --url \"${SENTRY_URL}\""
PROJECT_VERSION=$(sentry-cli releases propose-version)
2023-05-03 15:31:18 +02:00
2020-10-23 10:57:25 +02:00
$SENTRY_CMD \
releases \
--org "${sentry_org}" \
new \
-p "${sentry_project}" ${PROJECT_VERSION}
2023-05-03 15:31:18 +02:00
(
2020-10-23 10:57:25 +02:00
$SENTRY_CMD \
releases \
--org "${sentry_org}" \
set-commits --local \
${PROJECT_VERSION} || exit 0
)
$SENTRY_CMD \
releases \
--org "${sentry_org}" \
finalize \
${PROJECT_VERSION}
'''
}
}
}
}
}
post {
always {
cleanWs()
}
}
2023-05-03 15:31:18 +02:00
}