-
Notifications
You must be signed in to change notification settings - Fork 31
build: add a jenkinsfile to upload the release to Artifactory #1370
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /** | ||
| * Downloads a DDK release p2 update site from GitHub Releases and uploads it | ||
| * to the internal Artifactory p2-releases repository. | ||
| * | ||
| * Parameters: | ||
| * RELEASE_VERSION - The release version to publish (e.g. "18.0.0") | ||
| * ARTIFACTORY_REPO_URL - Base URL of the Artifactory repository | ||
| * ARTIFACTORY_SERVER_ID - Server ID in ~/.m2/settings.xml that holds the Artifactory credentials | ||
| * | ||
| * Required tools: | ||
| * curl, xmllint (available on the agent) | ||
| */ | ||
|
|
||
| pipeline { | ||
| agent { label 'linux' } | ||
|
|
||
| parameters { | ||
| string( | ||
| name: 'RELEASE_VERSION', | ||
| description: 'Release version to download from GitHub Releases and upload to Artifactory (e.g. 18.0.0)', | ||
| trim: true | ||
| ) | ||
| string( | ||
| name: 'ARTIFACTORY_REPO_URL', | ||
| description: 'Base URL of the Artifactory repository', | ||
| trim: true | ||
| ) | ||
| string( | ||
| name: 'ARTIFACTORY_SERVER_ID', | ||
| description: 'Server ID in ~/.m2/settings.xml that holds the Artifactory credentials', | ||
| trim: true | ||
| ) | ||
| } | ||
|
|
||
| environment { | ||
| GH_RELEASES_BASE_URL = 'https://github.com/dsldevkit/dsl-devkit/releases/download' | ||
| } | ||
|
|
||
| stages { | ||
| stage('Validate') { | ||
| steps { | ||
| script { | ||
| if (!params.RELEASE_VERSION) { | ||
| error 'RELEASE_VERSION parameter is required' | ||
| } | ||
| if (!params.ARTIFACTORY_REPO_URL) { | ||
| error 'ARTIFACTORY_REPO_URL parameter is required' | ||
| } | ||
| if (!params.ARTIFACTORY_SERVER_ID) { | ||
| error 'ARTIFACTORY_SERVER_ID parameter is required' | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Download from GitHub Releases') { | ||
| steps { | ||
| sh """ | ||
| curl --fail --silent --show-error --location \\ | ||
| "${GH_RELEASES_BASE_URL}/v${params.RELEASE_VERSION}/p2-update-site.zip" \\ | ||
| -o "p2-update-site-${params.RELEASE_VERSION}.zip" | ||
|
|
||
| echo "Downloaded p2-update-site-${params.RELEASE_VERSION}.zip" | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| stage('Upload to Artifactory') { | ||
| steps { | ||
| sh """ | ||
| set +x | ||
| ARTIFACTORY_USER=\$(xmllint --xpath "string(//server[id='${ARTIFACTORY_SERVER_ID}']/username)" ~/.m2/settings.xml) | ||
| ARTIFACTORY_PASS=\$(xmllint --xpath "string(//server[id='${ARTIFACTORY_SERVER_ID}']/password)" ~/.m2/settings.xml) | ||
|
|
||
| # Upload and explode the archive in Artifactory | ||
| curl --fail --silent --show-error \\ | ||
| -u "\${ARTIFACTORY_USER}:\${ARTIFACTORY_PASS}" \\ | ||
| -H "X-Explode-Archive: true" \\ | ||
| --upload-file "p2-update-site-${params.RELEASE_VERSION}.zip" \\ | ||
| "${ARTIFACTORY_REPO_URL}/${params.RELEASE_VERSION}/p2-update-site-${params.RELEASE_VERSION}.zip" | ||
|
|
||
| echo "Successfully uploaded release ${params.RELEASE_VERSION} to Artifactory" | ||
| """ | ||
| } | ||
| } | ||
| } | ||
|
|
||
| post { | ||
| always { | ||
| cleanWs() | ||
| } | ||
| success { | ||
| echo "Release ${params.RELEASE_VERSION} published to Artifactory at: ${ARTIFACTORY_REPO_URL}/${params.RELEASE_VERSION}/" | ||
| } | ||
| failure { | ||
| echo "Failed to publish release ${params.RELEASE_VERSION} to Artifactory" | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would check if the JFrog CLI is available and/or do this via maven deploy over custom curls, but don't want to block the PR on this.