-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor bugfix for signArtifacts.groovy (#1437)
* importing the key outside of if condition Signed-off-by: Abhinav Gupta <[email protected]> * added test cases for pgp and sign-artifacts job Signed-off-by: Abhinav Gupta <[email protected]> * moved variables for job in the job test case Signed-off-by: Abhinav Gupta <[email protected]> * add printurl library Signed-off-by: Abhinav Gupta <[email protected]> * added test case for printArtifactUrls Signed-off-by: Abhinav Gupta <[email protected]> * single line download and import key Signed-off-by: Abhinav Gupta <[email protected]> * remove extra line Signed-off-by: Abhinav Gupta <[email protected]> * added regression test file in tests folder Signed-off-by: Abhinav Gupta <[email protected]>
- Loading branch information
1 parent
84d8da0
commit 1f2608b
Showing
11 changed files
with
133 additions
and
104 deletions.
There are no files selected for viewing
This file contains 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
28 changes: 28 additions & 0 deletions
28
tests/jenkins/TestPrintArtifactDownloadUrlsForStaging.groovy
This file contains 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,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package jenkins.tests | ||
|
||
import org.junit.* | ||
|
||
|
||
class TestPrintArtifactDownloadUrlsForStaging extends BuildPipelineTest { | ||
|
||
@Before | ||
void setUp() { | ||
super.setUp() | ||
binding.setVariable('filenamesForUrls', ['dummy_file.tar.gz', 'dummy_file.tar.gz.sig']) | ||
binding.setVariable('UPLOAD_PATH', 'dummy/upload/path') | ||
} | ||
|
||
@Test | ||
void testPrintArtifactDownloadUrlsForStaging() { | ||
super.testPipeline("tests/jenkins/jobs/PrintArtifactDownloadUrlsForStaging_Jenkinsfile") | ||
} | ||
|
||
} |
This file contains 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
33 changes: 33 additions & 0 deletions
33
tests/jenkins/jenkinsjob-regression-files/sign-standalone-artifacts.jenkinsfile.txt
This file contains 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,33 @@ | ||
sign-standalone-artifacts.run() | ||
sign-standalone-artifacts.legacySCM(groovy.lang.Closure) | ||
sign-standalone-artifacts.library({identifier=jenkins@20211123, retriever=null}) | ||
sign-standalone-artifacts.pipeline(groovy.lang.Closure) | ||
sign-standalone-artifacts.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ci-runner-centos7-v1, reuseNode:false, stages:[:], args:, alwaysPull:true, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) | ||
sign-standalone-artifacts.stage(sign, groovy.lang.Closure) | ||
sign-standalone-artifacts.script(groovy.lang.Closure) | ||
sign-standalone-artifacts.sh(mkdir workspace/artifacts) | ||
sign-standalone-artifacts.sh(curl -SL https://www.dummy.com/dummy_1_artifact.tar.gz -o workspace/artifacts/dummy_1_artifact.tar.gz) | ||
sign-standalone-artifacts.sh(curl -SL https://www.dummy.com/dummy_2_artifact.tar.gz -o workspace/artifacts/dummy_2_artifact.tar.gz) | ||
sign-standalone-artifacts.signArtifacts({artifactPath=workspace/artifacts/, signatureType=.sig, distributionPlatform=linux}) | ||
signArtifacts.fileExists(workspace/sign.sh) | ||
signArtifacts.git({url=https://github.com/opensearch-project/opensearch-build.git, branch=main}) | ||
signArtifacts.sh(curl -sSL https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --import -) | ||
signArtifacts.usernamePassword({credentialsId=github_bot_token_name, usernameVariable=GITHUB_USER, passwordVariable=GITHUB_TOKEN}) | ||
signArtifacts.withCredentials([[GITHUB_USER, GITHUB_TOKEN]], groovy.lang.Closure) | ||
signArtifacts.sh( | ||
#!/bin/bash | ||
set +x | ||
export ROLE=dummy_signer_client_role | ||
export EXTERNAL_ID=signer_client_external_id | ||
export UNSIGNED_BUCKET=signer_client_unsigned_bucket | ||
export SIGNED_BUCKET=signer_client_signed_bucket | ||
|
||
workspace/sign.sh workspace/artifacts/ --sigtype=.sig --component=null --type=null | ||
) | ||
sign-standalone-artifacts.uploadToS3({sourcePath=workspace/artifacts, bucket=dummy_bucket_name, path=sign_artifacts_job/dummy/upload/path/20/dist/signed}) | ||
uploadToS3.withAWS({role=Dummy_Upload_Role, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) | ||
uploadToS3.s3Upload({file=workspace/artifacts, bucket=dummy_bucket_name, path=sign_artifacts_job/dummy/upload/path/20/dist/signed}) | ||
sign-standalone-artifacts.printArtifactDownloadUrlsForStaging({artifactFileNames=[dummy_1_artifact.tar.gz, dummy_1_artifact.tar.gz.sig, dummy_2_artifact.tar.gz, dummy_2_artifact.tar.gz.sig], uploadPath=sign_artifacts_job/dummy/upload/path/20/dist/signed}) | ||
sign-standalone-artifacts.script(groovy.lang.Closure) | ||
sign-standalone-artifacts.postCleanup() | ||
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true}) |
15 changes: 15 additions & 0 deletions
15
tests/jenkins/jobs/PrintArtifactDownloadUrlsForStaging_Jenkinsfile
This file contains 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,15 @@ | ||
pipeline { | ||
agent none | ||
stages { | ||
stage('print_urls') { | ||
steps { | ||
script { | ||
printArtifactDownloadUrlsForStaging( | ||
artifactFileNames: filenamesForUrls, | ||
uploadPath: UPLOAD_PATH | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/jenkins/jobs/PrintArtifactDownloadUrlsForStaging_Jenkinsfile.txt
This file contains 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,6 @@ | ||
PrintArtifactDownloadUrlsForStaging_Jenkinsfile.run() | ||
PrintArtifactDownloadUrlsForStaging_Jenkinsfile.pipeline(groovy.lang.Closure) | ||
PrintArtifactDownloadUrlsForStaging_Jenkinsfile.echo(Executing on agent [label:none]) | ||
PrintArtifactDownloadUrlsForStaging_Jenkinsfile.stage(print_urls, groovy.lang.Closure) | ||
PrintArtifactDownloadUrlsForStaging_Jenkinsfile.script(groovy.lang.Closure) | ||
PrintArtifactDownloadUrlsForStaging_Jenkinsfile.printArtifactDownloadUrlsForStaging({artifactFileNames=[dummy_file.tar.gz, dummy_file.tar.gz.sig], uploadPath=dummy/upload/path}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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,8 @@ | ||
void call(Map args = [:]){ | ||
|
||
for(filename in args.artifactFileNames){ | ||
url = "https://ci.opensearch.org/ci/dbc/${args.uploadPath}/${filename}" | ||
println("File ${filename} can be accessed using the url - ${url}" ) | ||
} | ||
|
||
} |
This file contains 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