Merge "[CORD-3039] new imagebuilder job"
diff --git a/jjb/imagebuilder.yaml b/jjb/imagebuilder.yaml
new file mode 100644
index 0000000..e29b11c
--- /dev/null
+++ b/jjb/imagebuilder.yaml
@@ -0,0 +1,74 @@
+---
+# CORD helm chart publishing tasks
+
+- project:
+ name: imagebuilder
+
+ # add repos that have documentation to the project list in both jobs
+ jobs:
+ - 'publish-imagebuilder':
+ project-regexp: '.*'
+ branch-regexp: '{supported-branches-regexp}'
+
+
+- job-template:
+ id: publish-imagebuilder
+ name: 'publish-imagebuilder'
+ description: |
+ Created by {id} job-template from ci-management/jjb/helm.yaml
+
+ triggers:
+ - cord-infra-gerrit-trigger-merge:
+ gerrit-server-name: '{gerrit-server-name}'
+ project-regexp: '{project-regexp}'
+ branch-regexp: '{branch-regexp}'
+ file-include-regexp: '{all-files-regexp}'
+ dependency-jobs: '{dependency-jobs}'
+
+ properties:
+ - cord-infra-properties:
+ build-days-to-keep: '{build-days-to-keep}'
+ artifact-num-to-keep: '{artifact-num-to-keep}'
+
+ wrappers:
+ - lf-infra-wrappers:
+ build-timeout: '{build-timeout}'
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+ parameters:
+ - string:
+ name: executorNode
+ default: 'imagebuilder_node'
+ description: 'Name of the Jenkins node to run the job on'
+
+ - string:
+ name: manifestUrl
+ default: '{gerrit-server-url}/{cord-repo-manifest}'
+ description: 'URL to the repo manifest'
+
+ - string:
+ name: manifestBranch
+ default: '$GERRIT_BRANCH'
+ description: 'Name of the repo branch to use'
+
+ - string:
+ name: gerritProject
+ default: '$GERRIT_PROJECT'
+ description: 'Name of the Gerrit project'
+
+ - bool:
+ name: build
+ default: false
+ description: 'Rebuild all containers (same as "docker build --no-cache")'
+
+ - bool:
+ name: force
+ default: false
+ description: 'Force remove obsolete tags/images (same as "docker rmi --force")'
+
+
+ project-type: pipeline
+ concurrent: false
+
+ dsl: !include-raw-escape: pipeline/imagebuilder.groovy
+
diff --git a/jjb/pipeline/imagebuilder.groovy b/jjb/pipeline/imagebuilder.groovy
new file mode 100644
index 0000000..b86bc22
--- /dev/null
+++ b/jjb/pipeline/imagebuilder.groovy
@@ -0,0 +1,79 @@
+/* imagebuilder pipeline */
+pipeline {
+
+ /* no label, executor is determined by JJB */
+ agent {
+ label "${params.executorNode}"
+ }
+ stages {
+
+ stage('repo') {
+ steps {
+ checkout(changelog: false, \
+ poll: false,
+ scm: [$class: 'RepoScm', \
+ manifestRepositoryUrl: "${params.manifestUrl}", \
+ manifestBranch: "${params.manifestBranch}", \
+ currentBranch: true, \
+ destinationDir: 'cord', \
+ forceSync: true,
+ resetFirst: true, \
+ quiet: true, \
+ jobs: 4, \
+ showAllChanges: true] \
+ )
+ }
+ }
+
+ stage('imagebuilder'){
+ steps {
+ sh '''
+ #!/usr/bin/env bash
+
+ mkdir "$WORKSPACE/image_logs"
+ ib_args=""
+
+ if [[ ${params.force} == 'true' ]]; then
+ ib_args+="--force "
+ fi
+
+ if [[ ${params.build} == 'true' ]]; then
+ ib_args+="--build "
+ fi
+
+ pushd cord/automation-tools/developer
+ ./imagebuilder.py -vv \${ib_args} -c docker_images.yml \
+ -a "$WORKSPACE/ib_actions.yml" \
+ -l "$WORKSPACE/ib_logs" \
+ -g "$WORKSPACE/ib_graph.dot"
+ popd
+ '''
+ }
+ }
+
+ stage('push'){
+ steps {
+ script {
+ def ib_actions = readYaml( file:"$WORKSPACE/ib_actions.yml" )
+
+ withDockerRegistry([credentialsId: 'docker-artifact-push-credentials']) {
+ for(image in ib_actions.ib_built){
+ for(tag in image.tags){
+ push_tag = image.base + ":" + tag
+ echo "Pushing image: " + push_tag
+ docker.image(push_tag).push()
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ post {
+ always {
+ archiveArtifacts artifacts: 'ib_actions.yml, ib_graph.dot, ib_logs/*', fingerprint: true
+ deleteDir()
+ }
+ }
+}