Skip to content

Commit

Permalink
Add sha512 generation to promotion job (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
peternied authored Dec 18, 2021
1 parent 7def587 commit ce15479
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 9 deletions.
4 changes: 3 additions & 1 deletion jenkins/promotion/tar-promotion.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ pipeline {
}
steps {
script {
promoteArtifacts()
promoteArtifacts(
fileActions: [createSha512()]
)
}
}
post() {
Expand Down
75 changes: 75 additions & 0 deletions tests/jenkins/TestPromoteArtifacts.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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.*
import java.util.*
import java.nio.file.*


class TestPromoteArtifacts extends BuildPipelineTest {
private Path target;

@Override
@Before
void setUp() {
super.setUp()

binding.setVariable('PUBLIC_ARTIFACT_URL', 'https://ci.opensearch.org/dbc')
binding.setVariable('DISTRIBUTION_JOB_NAME', 'vars-build')
binding.setVariable('ARTIFACT_BUCKET_NAME', 'artifact-bucket')
binding.setVariable('AWS_ACCOUNT_PUBLIC', 'account')
binding.setVariable('STAGE_NAME', 'stage')
binding.setVariable('BUILD_URL', 'http://jenkins.us-east-1.elb.amazonaws.com/job/vars/42')
binding.setVariable('DISTRIBUTION_BUILD_NUMBER', '33')
binding.setVariable('DISTRIBUTION_PLATFORM', 'x64')
binding.setVariable('DISTRIBUTION_ARCHITECTURE', 'linux')
binding.setVariable('ARTIFACT_DOWNLOAD_ROLE_NAME', 'downloadRoleName')
binding.setVariable('AWS_ACCOUNT_PUBLIC', 'publicAccount')
binding.setVariable('ARTIFACT_PROMOTION_ROLE_NAME', 'artifactPromotionRole')
binding.setVariable('AWS_ACCOUNT_ARTIFACT', 'artifactsAccount')
binding.setVariable('ARTIFACT_PRODUCTION_BUCKET_NAME', 'prod-bucket-name')
binding.setVariable('WORKSPACE', 'workspace')

helper.registerAllowedMethod("git", [Map])
helper.registerAllowedMethod("s3Download", [Map])
helper.registerAllowedMethod("s3Upload", [Map])
helper.registerAllowedMethod("withAWS", [Map, Closure], { args, closure ->
closure.delegate = delegate
return helper.callClosure(closure)
})
helper.registerAllowedMethod('getPath', { args ->
return "workspace/file/found.zip"
})
helper.registerAllowedMethod('findFiles', [Map], { args ->
return [{}]
})

Path source = Path.of("tests/data/opensearch-build-1.1.0.yml");
target = Path.of("artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/manifest.yml");
Files.createDirectories(target.getParent());
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
}

@After
void after() {
super.setUp()
Files.delete(target) // Test file needs to be cleaned up
}

@Test
public void testDefault() {
super.testPipeline("tests/jenkins/jobs/PromoteArtifacts_Jenkinsfile")
}

@Test
public void testWithActions() {
super.testPipeline("tests/jenkins/jobs/PromoteArtifacts_actions_Jenkinsfile")
}
}
14 changes: 14 additions & 0 deletions tests/jenkins/jobs/PromoteArtifacts_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pipeline {
agent none
stages {
stage('promote') {
steps {
script {
promoteArtifacts(
manifest: 'tests/jenkins/data/opensearch-1.3.0.yml'
)
}
}
}
}
}
39 changes: 39 additions & 0 deletions tests/jenkins/jobs/PromoteArtifacts_Jenkinsfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PromoteArtifacts_Jenkinsfile.run()
PromoteArtifacts_Jenkinsfile.pipeline(groovy.lang.Closure)
PromoteArtifacts_Jenkinsfile.echo(Executing on agent [label:none])
PromoteArtifacts_Jenkinsfile.stage(promote, groovy.lang.Closure)
PromoteArtifacts_Jenkinsfile.script(groovy.lang.Closure)
PromoteArtifacts_Jenkinsfile.promoteArtifacts({manifest=tests/jenkins/data/opensearch-1.3.0.yml})
promoteArtifacts.git({url=https://github.com/opensearch-project/opensearch-build.git, branch=main})
promoteArtifacts.legacySCM(groovy.lang.Closure)
promoteArtifacts.library({identifier=jenkins@20211123, retriever=null})
promoteArtifacts.readYaml({file=tests/jenkins/data/opensearch-1.3.0.yml})
InputManifest.asBoolean()
promoteArtifacts.withAWS({role=downloadRoleName, roleAccount=publicAccount, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
promoteArtifacts.s3Download({bucket=artifact-bucket, file=workspace/artifacts, path=vars-build/1.3.0/33/x64/linux/, force=true})
promoteArtifacts.readYaml({file=artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/manifest.yml})
promoteArtifacts.withAWS({role=artifactPromotionRole, roleAccount=artifactsAccount, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
promoteArtifacts.println(Start Core Plugin Promotion to artifects.opensearch.org Bucket)
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/discovery-ec2-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/discovery-ec2-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/transport-nio-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/transport-nio-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/discovery-gce-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/discovery-gce-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/analysis-ukrainian-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/analysis-ukrainian-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/discovery-azure-classic-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/discovery-azure-classic-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/analysis-phonetic-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/analysis-phonetic-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/mapper-murmur3-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/mapper-murmur3-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/analysis-kuromoji-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/analysis-kuromoji-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/analysis-stempel-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/analysis-stempel-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/mapper-annotated-text-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/mapper-annotated-text-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/repository-hdfs-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/repository-hdfs-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/analysis-icu-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/analysis-icu-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/mapper-size-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/mapper-size-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/ingest-attachment-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/ingest-attachment-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/repository-azure-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/repository-azure-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/repository-s3-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/repository-s3-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/analysis-nori-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/analysis-nori-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/store-smb-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/store-smb-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/analysis-smartcn-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/analysis-smartcn-1.1.0.zip*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/plugins/repository-gcs-1.1.0.zip/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/core-plugins/, includePathPattern=**/repository-gcs-1.1.0.zip*})
promoteArtifacts.println(Start Tar Core/Bundle Promotion to artifacts.opensearch.org Bucket)
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/core/opensearch/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/builds/opensearch/dist/, includePathPattern=**/opensearch-min-1.3.0*})
promoteArtifacts.s3Upload({bucket=prod-bucket-name, path=releases/bundle/opensearch/1.3.0/, workingDir=workspace/artifacts/vars-build/1.3.0/33/x64/linux/dist/opensearch/, includePathPattern=**/opensearch*-1.3.0*})
15 changes: 15 additions & 0 deletions tests/jenkins/jobs/PromoteArtifacts_actions_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pipeline {
agent none
stages {
stage('promote') {
steps {
script {
promoteArtifacts(
manifest: 'tests/jenkins/data/opensearch-1.3.0.yml',
fileActions: [createSha512()]
)
}
}
}
}
}
Loading

0 comments on commit ce15479

Please sign in to comment.