Skip to content

Commit

Permalink
Upload jenkinsio on Azure blob storage
Browse files Browse the repository at this point in the history
  • Loading branch information
olblak committed Sep 2, 2017
1 parent 67cccab commit a786b4b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def projectProperties = [
[$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']],
]

def azure_storageaccount_name = 'prodjenkinsio'

if (!env.CHANGE_ID) {
if (env.BRANCH_NAME == null) {
projectProperties.add(pipelineTriggers([cron('H/30 * * * *')]))
Expand Down Expand Up @@ -99,6 +101,12 @@ try {
}
}
}

if (infra.isTrusted()) {
stage('Publish on Azure file') {
sh './scripts/az storage file upload-batch --account-name ${azure_storageaccount_name} -d jenkinsio -s /data/build/_site'
}
}
}
catch (exc) {
echo "Caught: ${exc}"
Expand Down
31 changes: 31 additions & 0 deletions scripts/az
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
#
# This script is meant to be added to the PATH so the latest azure-cli is
# always ready to use

set +x

CONTAINER_NAME=azuresdk/azure-cli-python:0.1.5

pull_container() {
docker pull ${CONTAINER_NAME}
}

# Pull down the container if we don't already have it
docker inspect ${CONTAINER_NAME} > /dev/null 2>&1
if [ $? -ne 0 ]; then
pull_container
fi;

# http://blog.dscpl.com.au/2015/12/unknown-user-when-running-docker.html
# Passing LOGNAME and USER because the acs component in the azure-cli does some
# user lookup

exec docker run --rm -u "$(id -u):$(id -u)" \
-v "${HOME}/.azure:/.azure" \
-e LOGNAME="$LOGNAME" \
-e USER="$USER" \
-v "$PWD:/data" \
-t \
--workdir=/data \
"${CONTAINER_NAME}" /usr/local/bin/az "$@"

0 comments on commit a786b4b

Please sign in to comment.