Skip to content

Commit

Permalink
Added a default docker image into detectDockerImage. (opensearch-proj…
Browse files Browse the repository at this point in the history
…ect#1208)

Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock authored Dec 1, 2021
1 parent a26f152 commit 5351d72
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 2 deletions.
21 changes: 21 additions & 0 deletions tests/jenkins/TestDetectDockerImage.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.*

class TestDetectDockerImage extends BuildPipelineTest {
@Test
public void test() {
helper.registerAllowedMethod("git", [Map])

super.testPipeline("tests/jenkins/jobs/DetectDockerImage_Jenkinsfile")
}
}
49 changes: 49 additions & 0 deletions tests/jenkins/jobs/DetectDockerImage_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pipeline {
agent none
stages {
stage('opensearch-1.1.0') {
steps {
script {
dockerAgent = detectDockerAgent(
manifest: 'manifests/1.1.0/opensearch-1.1.0.yml'
)
echo dockerAgent.image
echo dockerAgent.args
}
}
}
stage('opensearch-1.2.0') {
steps {
script {
dockerAgent = detectDockerAgent(
manifest: 'manifests/1.2.0/opensearch-1.2.0.yml'
)
echo dockerAgent.image
echo dockerAgent.args
}
}
}
stage('opensearch-dashboards-1.1.0') {
steps {
script {
dockerAgent = detectDockerAgent(
manifest: 'manifests/1.1.0/opensearch-dashboards-1.1.0.yml'
)
echo dockerAgent.image
echo dockerAgent.args
}
}
}
stage('opensearch-dashboards-1.2.0') {
steps {
script {
dockerAgent = detectDockerAgent(
manifest: 'manifests/1.2.0/opensearch-dashboards-1.2.0.yml'
)
echo dockerAgent.image
echo dockerAgent.args
}
}
}
}
}
47 changes: 47 additions & 0 deletions tests/jenkins/jobs/DetectDockerImage_Jenkinsfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
DetectDockerImage_Jenkinsfile.run()
DetectDockerImage_Jenkinsfile.pipeline(groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.echo(Executing on agent [label:none])
DetectDockerImage_Jenkinsfile.stage(opensearch-1.1.0, groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.script(groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.detectDockerAgent({manifest=manifests/1.1.0/opensearch-1.1.0.yml})
detectDockerAgent.git({url=https://github.com/opensearch-project/opensearch-build.git, branch=main})
detectDockerAgent.legacySCM(groovy.lang.Closure)
detectDockerAgent.library({identifier=jenkins@20211123, retriever=null})
detectDockerAgent.readYaml({file=manifests/1.1.0/opensearch-1.1.0.yml})
InputManifest.asBoolean()
detectDockerAgent.echo(Using Docker image opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028 (null))
DetectDockerImage_Jenkinsfile.echo(opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028)
DetectDockerImage_Jenkinsfile.echo(null)
DetectDockerImage_Jenkinsfile.stage(opensearch-1.2.0, groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.script(groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.detectDockerAgent({manifest=manifests/1.2.0/opensearch-1.2.0.yml})
detectDockerAgent.git({url=https://github.com/opensearch-project/opensearch-build.git, branch=main})
detectDockerAgent.legacySCM(groovy.lang.Closure)
detectDockerAgent.library({identifier=jenkins@20211123, retriever=null})
detectDockerAgent.readYaml({file=manifests/1.2.0/opensearch-1.2.0.yml})
InputManifest.asBoolean()
detectDockerAgent.echo(Using Docker image opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028 (-e JAVA_HOME=/usr/lib/jvm/adoptopenjdk-14-hotspot))
DetectDockerImage_Jenkinsfile.echo(opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028)
DetectDockerImage_Jenkinsfile.echo(-e JAVA_HOME=/usr/lib/jvm/adoptopenjdk-14-hotspot)
DetectDockerImage_Jenkinsfile.stage(opensearch-dashboards-1.1.0, groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.script(groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.detectDockerAgent({manifest=manifests/1.1.0/opensearch-dashboards-1.1.0.yml})
detectDockerAgent.git({url=https://github.com/opensearch-project/opensearch-build.git, branch=main})
detectDockerAgent.legacySCM(groovy.lang.Closure)
detectDockerAgent.library({identifier=jenkins@20211123, retriever=null})
detectDockerAgent.readYaml({file=manifests/1.1.0/opensearch-dashboards-1.1.0.yml})
InputManifest.asBoolean()
detectDockerAgent.echo(Using Docker image opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211019 (null))
DetectDockerImage_Jenkinsfile.echo(opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211019)
DetectDockerImage_Jenkinsfile.echo(null)
DetectDockerImage_Jenkinsfile.stage(opensearch-dashboards-1.2.0, groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.script(groovy.lang.Closure)
DetectDockerImage_Jenkinsfile.detectDockerAgent({manifest=manifests/1.2.0/opensearch-dashboards-1.2.0.yml})
detectDockerAgent.git({url=https://github.com/opensearch-project/opensearch-build.git, branch=main})
detectDockerAgent.legacySCM(groovy.lang.Closure)
detectDockerAgent.library({identifier=jenkins@20211123, retriever=null})
detectDockerAgent.readYaml({file=manifests/1.2.0/opensearch-dashboards-1.2.0.yml})
InputManifest.asBoolean()
detectDockerAgent.echo(Using Docker image opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028 (null))
DetectDockerImage_Jenkinsfile.echo(opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028)
DetectDockerImage_Jenkinsfile.echo(null)
4 changes: 2 additions & 2 deletions vars/detectDockerAgent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Map call(Map args = [:]) {
def lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm))
String manifest = args.manifest ?: "manifests/${INPUT_MANIFEST}"
def inputManifest = lib.jenkins.InputManifest.new(readYaml(file: manifest))
dockerImage = inputManifest.ci.image.name
dockerArgs = inputManifest.ci.image.args
dockerImage = inputManifest.ci?.image?.name ?: 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028'
dockerArgs = inputManifest.ci?.image?.args
echo "Using Docker image ${dockerImage} (${dockerArgs})"
return [
image: dockerImage,
Expand Down

0 comments on commit 5351d72

Please sign in to comment.