blob: cf31d3d1df3b266a20a288412f59fd4cdd7a58d7 [file] [log] [blame]
def call(body) {
// evaluate the body block, and collect configuration into the object
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
def dockerRepo = config.dockerRepo ?: "artifactory.mcp.mirantis.net:5001"
def artifactoryUrl = config.artifactoryURL ?: "https://artifactory.mcp.mirantis.net/artifactory/projectcalico"
def nodeImage = config.nodeImage ?: "calico/node"
def nodeImageTag = config.nodeImageTag ?: "v0.20.0"
def nodeName = "${dockerRepo}/${nodeImage}:${nodeImageTag}"
def ctlImage = config.ctlImage ?: "calico/ctl"
def ctlImageTag = config.ctlImageTag ?: "v0.20.0"
def ctlName = "${dockerRepo}/${ctlImage}:${ctlImageTag}"
// calico/build goes from {artifactoryUrl}/mcp/libcalico/
def buildImage = config.buildImage ?: "${artifactoryUrl}/mcp/libcalico/lastbuild".toURL().text.trim()
// calico/felix goes from {artifactoryUrl}/mcp/felix/
def felixImage = config.felixImage ?: "${artifactoryUrl}/mcp/felix/lastbuild".toURL().text.trim()
def confdBuildId = config.confdBuildId ?: "${artifactoryUrl}/mcp/confd/lastbuild".toURL().text.trim()
def confdUrl = config.confdUrl ?: "${artifactoryUrl}/mcp/confd/confd-${confdBuildId}"
def birdBuildId = config.birdBuildId ?: "${artifactoryUrl}/mcp/calico-bird/lastbuild".toURL().text.trim()
def birdUrl = config.birdUrl ?: "${artifactoryUrl}/mcp/calico-bird/bird-${birdBuildId}"
def bird6Url = config.bird6Url ?: "${artifactoryUrl}/mcp/calico-bird/bird6-${birdBuildId}"
def birdclUrl = config.birdclUrl ?: "${artifactoryUrl}/mcp/calico-bird/birdcl-${birdBuildId}"
def gitCommit = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim()
def build = "${config.containersBuildId}-${gitCommit}"
// return values
def calicoNodeImageRepo = "${dockerRepo}/${nodeImage}"
def calicoCtlImageRepo = "${dockerRepo}/${ctlImage}"
def calicoVersion = "${nodeImageTag}-${build}"
def ctlContainerName = "${ctlName}-${build}"
def nodeContainerName = "${nodeName}-${build}"
// Start build section
stage ('Build calico/ctl image'){
sh """
make calico/ctl \
CTL_CONTAINER_NAME=${ctlContainerName} \
BUILD_CONTAINER_NAME=${buildImage} \
BIRDCL_URL=${birdclUrl}
"""
}
stage('Build calico/node'){
sh """
make calico/node \
NODE_CONTAINER_NAME=${nodeContainerName} \
BUILD_CONTAINER_NAME=${buildImage} \
FELIX_CONTAINER_NAME=${felixImage} \
CONFD_URL=${confdUrl} \
BIRD_URL=${birdUrl} \
BIRD6_URL=${bird6Url} \
BIRDCL_URL=${birdclUrl}
"""
}
dir("artifacts"){
// Save the last build ID
writeFile file: "lastbuild", text: "${build}"
// Create config yaml for Kargo
writeFile file: "calico-containers-${build}.yaml",
text: """\
calico_node_image_repo: ${calicoNodeImageRepo}
calicoctl_image_repo: ${calicoCtlImageRepo}
calico_version: ${calicoVersion}
""".stripIndent()
} // dir artifacts
return [
CTL_CONTAINER_NAME:"${ctlContainerName}",
NODE_CONTAINER_NAME:"${nodeContainerName}",
CALICO_NODE_IMAGE_REPO:"${calicoNodeImageRepo}",
CALICOCTL_IMAGE_REPO:"${calicoCtlImageRepo}",
CALICO_VERSION: "${calicoVersion}"
]
}