Browse Source

Fix version number format issue

master
Luciano Silva 8 years ago
parent
commit
fdf353f875
  1. 16
      assets/common.sh
  2. 5
      pipeline.yml

16
assets/common.sh

@ -21,14 +21,16 @@ check_version() {
local httpHeader=$(curl -R -I $1 2>&1 | grep 'Last-Modified:') local httpHeader=$(curl -R -I $1 2>&1 | grep 'Last-Modified:')
# Checks if field "Last-Modified" exists in HTTP header and transform it into timestamp string # Checks if field "Last-Modified" exists in HTTP header and transform it into timestamp string
# if that field is not present, return current timestamp # if that field is not present, return current timestamp
if [ -z "$httpHeader" ]
local dateVersionFormat="%Y%m%d%H%S"
local dateString=$(date +"$dateVersionFormat")
if [ ! -z "$httpHeader" ]
then then
# echo "Last-Modified information not returned for targeted file. Using current date's timestamp as version number."
local dateString=$(date)
else
# echo "$httpHeader"
local dateString=$(echo "$httpHeader" | sed -e "s/Last-Modified: //" | cut -d',' -f 2)
# echo "Last-Modified information returned for targeted file. Extract date, removing day of the week string
local tmpDateString=$(echo "$httpHeader" | sed -e "s/Last-Modified: //" | cut -d',' -f 2)
# rfc1123Format="%d\ %b\ %Y\ %H:%M:%S\ GMT" - in order to work in boot2docker, it has to be outside of quotes in the command below
local dateString=$(date +"$dateVersionFormat" -D %d\ %b\ %Y\ %H:%M:%S\ GMT -d "$tmpDateString")
fi fi
date +"%Y%m%d%H%S" -d "$dateString"
echo "$dateString"
} }

5
pipeline.yml

@ -7,13 +7,14 @@ resource_types:
resources: resources:
- name: single-file - name: single-file
type: curl type: curl
check_every: 1m
source: source:
url: https://s3-us-west-1.amazonaws.com/lsilva-bpws/PCF_usage/pcf-sandbox-usage-from-2016-09-01-to-2016-09-30_1475771124.json url: https://s3-us-west-1.amazonaws.com/lsilva-bpws/PCF_usage/pcf-sandbox-usage-from-2016-09-01-to-2016-09-30_1475771124.json
filename: pcf-sandbox.json filename: pcf-sandbox.json
jobs: jobs:
- name: run-and-get-file - name: run-and-get-file
plan: plan:
- get: single-file
- task: run-and-get-file - task: run-and-get-file
config: config:
platform: linux platform: linux
@ -23,7 +24,7 @@ jobs:
repository: ubuntu repository: ubuntu
tag: "latest" tag: "latest"
inputs: inputs:
- single-file
- name: single-file
run: run:
path: sh path: sh
args: args:

Loading…
Cancel
Save