Skip to content

Commit

Permalink
Make it more strong
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemric committed Nov 24, 2023
1 parent 662b1fa commit 6b79c0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,20 @@ pipeline {
steps {
sh '''
./Update.sh --stream $STREAM --arch $ARCH --artifact $ARTIFACT --format $FORMAT --verbose true
if ls *.$STREAM; then touch updated; fi;
'''
}
}

stage("Upload Files") {
when { expression { fileExists('updated') } }
when { expression { fileExists('$FORMAT.$ARTIFACT.$ARCH.$STREAM') } }
steps {
sshagent(credentials: ['Jenkins-Key']) {
sh '''
echo uploading *.$STREAM files
scp *.$STREAM jenkins@$ARTEFACTS_SERVER:/media/img/coreos/
files=$(cat $FORMAT.$ARTIFACT.$ARCH.$STREAM)
echo uploading $FORMAT.$ARTIFACT.$ARCH.$STREAM files
scp $files jenkins@$ARTEFACTS_SERVER:/media/img/coreos/
'''
sh 'touch updated'
}
}
}
Expand Down
27 changes: 19 additions & 8 deletions Update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ stream="stable"
arch="x86_64"
artifact="metal"
format="pxe"
versions='coreos.json'
history='coreos.json'
streampath='https://builds.coreos.fedoraproject.org/streams'
verbose=false

Expand All @@ -29,6 +29,9 @@ while [ $# -gt 0 ]; do
-v|--verbose)
verbose="$2"
;;
-h|--history)
history="$2"
;;
*)
printf "***************************\n"
printf "* Error: Invalid argument.*\n"
Expand All @@ -38,8 +41,9 @@ while [ $# -gt 0 ]; do
shift
shift
done

echo Looking for previous files
jqverbose "$(cat $versions)"
jqverbose "$(cat $history)"

data="$streampath/$stream.json"
echo "Checking updates for $stream stream from : $data"
Expand All @@ -49,15 +53,14 @@ data=$(curl --no-progress-meter $data | jq .architectures.$arch.artifacts.$artif
jqverbose "${data}"

FCOSrelease=$(jq -n "$data" | jq --raw-output .release)
FCOSversion=$(jq --raw-output .$stream.$arch.$artifact.$format $versions)
FCOSversion=$(jq --raw-output .$stream.$arch.$artifact.$format $history)

if [ "${FCOSversion}" = "null" ]
then
FCOSversion=0
fi
if [ "${FCOSversion}" = "null" ]; then FCOSversion=0; fi;

echo FCOSrelease: $FCOSrelease / FCOSversion: $FCOSversion

failed=false

if $(jq -n "$data" | jq --raw-output --arg version $FCOSversion '.release > $version')
then
echo "Looking for $format files"
Expand All @@ -80,13 +83,21 @@ then
echo "Check sha256sum and GPG signature"
if echo "$(jq -n "$fileinfo" | jq --raw-output .sha256) $filename" | sha256sum --check && gpg --verify $filename.sig
then
echo $filename >> $format.$artifact.$arch.$stream
break
else
rm $filename $filename.sig
fi
failed=true

done
done
cat <<< $(jq --arg release $FCOSrelease '.'$stream'.'$arch'.'$artifact'.'$format' = $release' $versions) > $versions

if ! $failed
then
cat <<< $(jq --arg release $FCOSrelease '.'$stream'.'$arch'.'$artifact'.'$format' = $release' $history) > $history
fi

else
echo "Up to date, nothing to do"
fi

0 comments on commit 6b79c0a

Please sign in to comment.