resources: - name: build_alpine_ci_repo type: gitRepo integration: drship_github #replace with your Github integration, if needed pointer: sourceName: "devops-recipes/build_alpine_ci_image" #org name/repository name branch: master - name: build_alpine_ci_img_dh type: image integration: drship_dockerhub # replace with your integration name versionTemplate: sourceName: "devopsrecipes/build_alpine_ci" # replace with your Hub URL versionName: latest - name: build_docker_ci_img_dh type: image integration: drship_dockerhub # replace with your integration name versionTemplate: sourceName: "devopsrecipes/build_docker_ci" # replace with your Hub URL versionName: latest jobs: - name: build_alpine_img type: runSh steps: - IN: build_alpine_ci_repo - TASK: name: build_image runtime: options: env: - RES_OUT_IMG: "build_alpine_ci_img_dh" script: # Extract image information and Docker registry credentials from resources using shipctl utility # Detailed shipctl guide is at http://docs.shippable.com/platform/tutorial/workflow/using-shipctl/ - IMG_NAME=$(shipctl get_resource_version_key "$RES_OUT_IMG" "sourceName") - DH_USR_NAME=$(shipctl get_integration_resource_field "$RES_OUT_IMG" "userName") - DH_PASS=$(shipctl get_integration_resource_field "$RES_OUT_IMG" "password") - DH_URL=$(shipctl get_integration_resource_field "$RES_OUT_IMG" "url") - pushd $(shipctl get_resource_state "build_alpine_ci_repo") - docker build -t=$IMG_NAME:$BUILD_NUMBER -f Dockerfile.alpine37 --pull . - docker login -u $DH_USR_NAME -p $DH_PASS - docker push $IMG_NAME:$BUILD_NUMBER - OUT: build_alpine_ci_img_dh on_success: script: # Update OUT resource to create a new version that will trigger rest of the workflow - shipctl put_resource_state_multi "$RES_OUT_IMG" "versionName=$BUILD_NUMBER" flags: - alpine_ci_img - ci - name: test_alpine_img type: runSh steps: - IN: build_alpine_ci_img_dh - TASK: name: set_env runtime: container: false script: # this is very hacky as its hardcoding the boot script location. # we need to create a shipctl to abstract this out # if you dont want to do this, hard code the imageName and tag, rather than making # it dynamic # Basically, this is getting the boot script of next task, then injecting the # env vars after the shebang line - ALP_IMG=$(shipctl get_resource_version_key build_alpine_ci_img_dh "sourceName") - ALP_IMG_TAG=$(shipctl get_resource_version_key build_alpine_ci_img_dh "versionName") - NEXT_BOOT_SCRIPT_PATH="$BUILD_DIR/scripts/yml_boot_1.sh" - NEXT_BOOT_SCRIPT_WITHOUT_SHEBANG=$(cat $NEXT_BOOT_SCRIPT_PATH | tail -n +2) - | echo "#!/bin/bash -e export ALP_IMG=$ALP_IMG export ALP_IMG_TAG=$ALP_IMG_TAG $NEXT_BOOT_SCRIPT_WITHOUT_SHEBANG " > $NEXT_BOOT_SCRIPT_PATH - TASK: name: test_image runtime: options: imageName: $ALP_IMG imageTag: $ALP_IMG_TAG script: - python -V flags: - alpine_ci_img - ci - name: build_docker_img type: runSh steps: - IN: build_alpine_ci_repo - TASK: name: build_image runtime: options: env: - RES_OUT_IMG: "build_docker_ci_img_dh" script: # Extract image information and Docker registry credentials from resources using shipctl utility # Detailed shipctl guide is at http://docs.shippable.com/platform/tutorial/workflow/using-shipctl/ - IMG_NAME=$(shipctl get_resource_version_key "$RES_OUT_IMG" "sourceName") - DH_USR_NAME=$(shipctl get_integration_resource_field "$RES_OUT_IMG" "userName") - DH_PASS=$(shipctl get_integration_resource_field "$RES_OUT_IMG" "password") - DH_URL=$(shipctl get_integration_resource_field "$RES_OUT_IMG" "url") - pushd $(shipctl get_resource_state "build_alpine_ci_repo") - docker build -t=$IMG_NAME:$BUILD_NUMBER -f Dockerfile.docker --pull . - docker login -u $DH_USR_NAME -p $DH_PASS - docker push $IMG_NAME:$BUILD_NUMBER - OUT: build_docker_ci_img_dh on_success: script: # Update OUT resource to create a new version that will trigger rest of the workflow - shipctl put_resource_state_multi "$RES_OUT_IMG" "versionName=$BUILD_NUMBER" flags: # Use flags to filter SPOG views - docker_ci_img - ci