Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor jenkins pipeline to support multi-platform artifacts #55

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
179 changes: 150 additions & 29 deletions jenkins/release.jenkinsFile
Original file line number Diff line number Diff line change
@@ -1,35 +1,156 @@
/*
* Copyright OpenSearch Contributors
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
lib = library(identifier: 'jenkins@4.4.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))

standardReleasePipelineWithGenericTrigger(
tokenIdCredential: 'jenkins-sql-odbc-generic-webhook-token',
causeString: 'A tag was cut on opensearch-project/sql-odbc repository causing this workflow to run',
downloadReleaseAsset: true,
publishRelease: true) {
publishToArtifactsProdBucket(
assumedRoleName: 'sql-odbc-upload-role',
source: 'windows32-installer/OpenSearch-SQL-ODBC-Driver-32-bit-1.5.0.0-Windows.msi',
destination: 'opensearch-clients/odbc/opensearch-sql-odbc-driver-32-bit-1.5.0.0-Windows.msi',
signingPlatform: 'windows',
sigType: 'null',
sigOverwrite: true
)
publishToArtifactsProdBucket(
assumedRoleName: 'sql-odbc-upload-role',
source: 'windows64-installer/OpenSearch-SQL-ODBC-Driver-64-bit-1.5.0.0-Windows.msi',
destination: 'opensearch-clients/odbc/opensearch-sql-odbc-driver-64-bit-1.5.0.0-Windows.msi',
signingPlatform: 'windows',
sigType: 'null',
sigOverwrite: true
)
publishToArtifactsProdBucket(
assumedRoleName: 'sql-odbc-upload-role',
source: 'mac64-installer/OpenSearch-SQL-ODBC-Driver-64-bit-1.5.0.0-Darwin.pkg',
destination: 'opensearch-clients/odbc/opensearch-sql-odbc-driver-64-bit-1.5.0.0-Darwin.pkg',
signingPlatform: 'mac',
sigType: 'null',
sigOverwrite: true
)
pipeline {
agent none
options {
timeout(time: 1, unit: 'HOURS')
}
triggers {
GenericTrigger(
genericVariables: [
[key: 'ref', value: ('$.release.tag_name')],
[key: 'repository', value: '$.repository.html_url'],
[key: 'action', value: '$.action'],
[key: 'isDraft', value: '$.release.draft'],
[key: 'release_url', value: '$.release.url'],
[key: 'assets_url', value: '$.release.assets_url']
],
tokenCredentialId: 'jenkins-sql-odbc-generic-webhook-token',
causeString: 'A tag was cut on opensearch-project/sql-odbc repository causing this workflow to run',
printContributedVariables: false,
printPostContent: false,
regexpFilterText: ('$isDraft $action'),
regexpFilterExpression: ('^true created$')
)
}
environment {
tag = "$ref"
repository = "$repository"
}
stages {
stage('Download artifacts') {
agent {
docker {
label 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:release-centos7-clients-v1'
args '-e JAVA_HOME=/opt/java/openjdk-11'
alwaysPull true
}
}
steps {
script {
if ("$assets_url" != '') {
withCredentials([usernamePassword(credentialsId: 'jenkins-github-bot-token', usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')]) {
String assets = sh(
script: "curl -H 'Accept: application/vnd.github+json' -H 'Authorization: Bearer ${GITHUB_TOKEN}' ${assets_url}",
returnStdout: true
)
String assetUrl = null
def parsedJson = readJSON text: assets
def assetName = 'artifacts.tar.gz'
parsedJson.each { item ->
if (item.name == assetName) {
assetUrl = item.url
}
}
echo "Downloading artifacts from $assetUrl"
sh "curl -J -L -H 'Accept: application/octet-stream' -H 'Authorization: Bearer ${GITHUB_TOKEN}' ${assetUrl} -o artifacts.tar.gz && tar -xvf artifacts.tar.gz"
stash includes: '**', name: 'odbc-release-artifacts'
}
}
}
}
}
stage('Release artifacts') {
parallel {
stage('Release Windows artifacts') {
agent {
docker {
label 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:release-centos7-clients-v1'
args '-e JAVA_HOME=/opt/java/openjdk-11'
alwaysPull true
}
}
steps {
script {
unstash 'odbc-release-artifacts'
sh 'ls -l'
publishToArtifactsProdBucket(
assumedRoleName: 'sql-odbc-upload-role',
source: "${WORKSPACE}/windows32-installer/OpenSearch-SQL-ODBC-Driver-32-bit-${tag}-Windows.msi",
destination: "opensearch-clients/odbc/opensearch-sql-odbc-driver-32-bit-${tag}-Windows.msi",
signingPlatform: 'windows',
sigOverwrite: true
)
publishToArtifactsProdBucket(
assumedRoleName: 'sql-odbc-upload-role',
source: "${WORKSPACE}/windows64-installer/OpenSearch-SQL-ODBC-Driver-64-bit-${tag}-Windows.msi",
destination: "opensearch-clients/odbc/opensearch-sql-odbc-driver-64-bit-${tag}-Windows.msi",
signingPlatform: 'windows',
sigOverwrite: true
)
}
}
}
stage('Release Mac Artifacts') {
agent {
node {
label 'Jenkins-Agent-MacOS12-X64-Mac1Metal-Multi-Host'
}
}
steps {
script {
unstash 'odbc-release-artifacts'
publishToArtifactsProdBucket(
assumedRoleName: 'sql-odbc-upload-role',
source: "${WORKSPACE}/mac64-installer/OpenSearch-SQL-ODBC-Driver-64-bit-${tag}-Darwin.pkg",
destination: "opensearch-clients/odbc/opensearch-sql-odbc-driver-64-bit-${tag}-Darwin.pkg",
signingPlatform: 'mac',
sigOverwrite: true
)
}
}
post {
always {
script {
postCleanup()
}
}
}
}
}
}
}
post {
success {
node('Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host') {
script {
if (release_url != null) {
withCredentials([usernamePassword(credentialsId: 'jenkins-github-bot-token', usernameVariable: 'GITHUB_USER', passwordVariable: 'GITHUB_TOKEN')]) {
sh "curl -X PATCH -H 'Accept: application/vnd.github+json' -H 'Authorization: Bearer ${GITHUB_TOKEN}' ${release_url} -d '{\"tag_name\":\"${tag}\",\"draft\":false,\"prerelease\":false}'"
}
}
}
}
}
always {
node('Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host') {
script {
postCleanup()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

* ODBC SSL Compliance Fix ([#653](https://github.com/opensearch-project/sql/pull/653))
* Reverted UseSSL flag to false and removed invalid test case ([#671](https://github.com/opensearch-project/sql/pull/671))
* Fix jenkins lib version to accommodate mac signing ([#54](https://github.com/opensearch-project/sql-odbc/pull/54))
* Fix and refactor jenkins lib version to accommodate multi-platform artifacts ([#54](https://github.com/opensearch-project/sql-odbc/pull/54) [#55](https://github.com/opensearch-project/sql-odbc/pull/55))

### Documentation

Expand Down
Loading