Skip to content
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
893792a
PMM-133487 Pipeline for PMM feature builds
ademidoff Dec 4, 2024
a7013f4
PMM-133487 Fix the branch param
ademidoff Dec 4, 2024
7e816db
PMM-133487 Use the JK creds to pull from git
ademidoff Dec 4, 2024
3d2adc6
PMM-133487 Create ci.yml on the fly
ademidoff Dec 4, 2024
4566975
PMM-133487 Use tabs for the heredoc
ademidoff Dec 4, 2024
93d1b10
PMM-133487 Use more tabs for the heredoc
ademidoff Dec 4, 2024
8749790
PMM-133487 Check if the file exists
ademidoff Dec 4, 2024
d2fcb39
PMM-133487 Check if the file exists
ademidoff Dec 4, 2024
910bea9
PMM-133487 Fix the heredoc syntax
ademidoff Dec 4, 2024
78d2f66
PMM-133487 Fix a typo
ademidoff Dec 4, 2024
edcc2ea
PMM-133487 Use print instead of heredoc
ademidoff Dec 4, 2024
30a25ab
PMM-133487 Fix the left padding
ademidoff Dec 4, 2024
2b563af
PMM-133487 Don't use JK's error
ademidoff Dec 4, 2024
b72b3b2
PMM-133487 Fix PR number, add docker push command
ademidoff Dec 5, 2024
deb785b
PMM-133487 Add docker server build step
ademidoff Dec 5, 2024
c290e5a
PMM-13487 Rename FB to PR
ademidoff Dec 7, 2024
be7d1c6
Merge branch 'master' into PMM-13487-build-pmm-locally
ademidoff Dec 7, 2024
cd5afc8
PMM-13487 Add the client tarball to the message
ademidoff Dec 7, 2024
cab469c
PMM-13487 Fix the image name
ademidoff Dec 7, 2024
11264d4
PMM-13487 Move FB docker tag creation to the repo
ademidoff Dec 7, 2024
4af2ece
PMM-13487 Fix the PR_NUMBER envvar
ademidoff Dec 8, 2024
1e06acc
PMM-13487 Move the creation of the default ci.yml to the repo
ademidoff Dec 8, 2024
7557da8
PMM-13487 Prevent github from parsing image names as urls
ademidoff Dec 8, 2024
5b3b580
PMM-13487 Add github authorization
ademidoff Dec 8, 2024
116fd21
PMM-13487 Get rid of the github token
ademidoff Dec 10, 2024
2ff23a0
PMM-13487 Refactor the code
ademidoff Dec 15, 2024
802d76a
Merge branch 'master' into PMM-13487-build-pmm-locally
ademidoff Dec 21, 2024
af87b84
PMM-13487 clean up unused code
ademidoff Jul 11, 2025
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
109 changes: 109 additions & 0 deletions pmm/v3/pmm3-feature-build.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import groovy.json.JsonOutput

library changelog: false, identifier: 'lib@master', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/Percona-Lab/jenkins-pipelines.git'
]) _

void addIssueComment(String PR_NUMBER, String COMMENT, String GITHUB_API_TOKEN) {
writeFile(file: 'body.json', text: JsonOutput.toJson([ body: "${COMMENT}" ]))
sh '''
curl -s -X POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Authorization: token ${GITHUB_API_TOKEN}" \
-d @body.json \
"https://api.github.com/repos/percona/pmm/issues/${PR_NUMBER}/comments"
'''
}

pipeline {
agent {
label 'agent-amd64-ol9'
}
parameters {
string(
name: 'PMM_BRANCH',
defaultValue: '',
description: 'A branch name in percona/pmm repository'
)
}
environment {
PATH_TO_SCRIPTS = 'build/scripts'
// https://www.jenkins.io/doc/book/pipeline/syntax/#supported-credentials-type
GITHUB_SSH_KEY = credentials('GitHub SSH Key')
DOCKER_CREDS = credentials('hub.docker.com')
GITHUB_API_TOKEN = credentials('GITHUB_API_TOKEN')
}
stages {
stage('Prepare') {
steps {
git poll: false,
changelog: false,
branch: PMM_BRANCH,
url: 'http://github.com/percona/pmm'

script {
sh 'echo "${DOCKER_CREDS_PSW}" | docker login -u "${DOCKER_CREDS_USR}" --password-stdin'
}
script {
sh '''
set -o errexit
export GIT_SSH_COMMAND="/usr/bin/ssh -i ${GITHUB_SSH_KEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"

./build.sh --init
'''
}
script {
env.PMM_VERSION = sh(returnStdout: true, script: "cat .modules/VERSION").trim()
env.FB_COMMIT = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
}
}
}
stage('Build PMM') {
steps {
withCredentials([
aws(credentialsId: 'AMI/OVF', accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')
]) {
sh '''
set -o errexit
export GIT_SSH_COMMAND="/usr/bin/ssh -i ${GITHUB_SSH_KEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"

./build.sh

docker push $(cat .modules/build/docker/CLIENT_TAG)
docker push $(cat .modules/build/docker/TAG)
'''
}
script {
if (!fileExists('.modules/build/docker/CLIENT_TAG')) {
error "Client image could not be built."
}
if (!fileExists('.modules/build/docker/TAG')) {
error "Server image could not be built."
}
env.CLIENT_URL = sh(returnStdout: true, script: "cat .modules/build/S3_TARBALL_URL")
env.PR_NUMBER = sh(returnStdout: true, script: "cat .modules/build/PR_NUMBER")
env.CLIENT_IMAGE = sh(returnStdout: true, script: "cat .modules/build/docker/CLIENT_TAG")
env.SERVER_IMAGE = sh(returnStdout: true, script: "cat .modules/build/docker/TAG")
}
}
}
}
post {
success {
script {
slackSend channel: '#pmm-notifications', color: '#00FF00', message: "[${JOB_NAME}]: build finished, image: ${SERVER_IMAGE}, URL: ${BUILD_URL}"
def STAGING_URL = "https://pmm.cd.percona.com/job/pmm3-aws-staging-start/parambuild/"
def MESSAGE = "Server docker: `${SERVER_IMAGE}`\nClient docker: `${CLIENT_IMAGE}`\nClient tarball: ${CLIENT_URL}\n"
MESSAGE += "Staging instance: ${STAGING_URL}?DOCKER_VERSION=${SERVER_IMAGE}&CLIENT_VERSION=${CLIENT_URL}"
addIssueComment(env.PR_NUMBER, MESSAGE, GITHUB_API_TOKEN)
}
}
failure {
script {
slackSend channel: '#pmm-notifications', color: '#FF0000', message: "[${JOB_NAME}]: build ${currentBuild.result}, URL: ${BUILD_URL}"
}
}
}
}