Last active
February 2, 2018 00:31
-
-
Save herpiko/e11b97fd999fc669e9dbc8deab41ae93 to your computer and use it in GitHub Desktop.
Fetch artifacts' URL from Appveyor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LATEST=$(git ls-remote https://gitlab.com/KodeKreatif/erpiko.git | grep master) | |
| if [ -z "$LATEST" ]; then | |
| exit 1 | |
| fi | |
| LATEST=$(echo $LATEST | cut -d' ' -f1) | |
| URL="https://gitlab.com/KodeKreatif/erpiko/commit/$LATEST/pipelines" | |
| PIPELINE_ID=$(curl $URL | grep passed | grep external | cut -d/ -f5) | |
| if [ -z "$PIPELINE_ID" ]; then | |
| exit 1 | |
| fi | |
| BUILD_URL=$(curl "https://gitlab.com/KodeKreatif/erpiko/pipelines/$PIPELINE_ID" | grep ci-success | grep appveyor | head -n 1 | cut -d\" -f4) | |
| if [ -z "$BUILD_URL" ]; then | |
| exit 1 | |
| fi | |
| BUILD_API_URL="${BUILD_URL/project/api\/projects}" | |
| JOB_NAMES=$(curl $BUILD_API_URL | python -mjson.tool | grep Configuration) | |
| if [ -z "$JOB_NAMES" ]; then | |
| exit 1 | |
| fi | |
| JOBS=$(curl $BUILD_API_URL | python -mjson.tool | grep jobId) | |
| if [ -z "$JOBS" ]; then | |
| exit 1 | |
| fi | |
| ### There are 4 builds for each job | |
| #### First | |
| URL=$(echo $JOB_NAMES | cut -d, -f1 | cut -d\" -f4) | |
| FILENAME=$(echo $URL | sed -e "s/: //g" | sed -e "s/; //g") | |
| touch $FILENAME.txt | |
| BUILD_CONF_ID=$(echo $JOBS | cut -d, -f1 | cut -d\" -f4) | |
| ARTIFACT_URL="https://ci.appveyor.com/api/buildjobs/$BUILD_CONF_ID/artifacts/erpiko.zip" | |
| echo $ARTIFACT_URL > $FILENAME.txt | |
| #### Second | |
| URL=$(echo $JOB_NAMES | cut -d, -f2 | cut -d\" -f4) | |
| FILENAME=$(echo $URL | sed -e "s/: //g" | sed -e "s/; //g") | |
| touch $FILENAME.txt | |
| BUILD_CONF_ID=$(echo $JOBS | cut -d, -f2 | cut -d\" -f4) | |
| ARTIFACT_URL="https://ci.appveyor.com/api/buildjobs/$BUILD_CONF_ID/artifacts/erpiko.zip" | |
| echo $ARTIFACT_URL > $FILENAME.txt | |
| #### Third | |
| URL=$(echo $JOB_NAMES | cut -d, -f3 | cut -d\" -f4) | |
| FILENAME=$(echo $URL | sed -e "s/: //g" | sed -e "s/; //g") | |
| touch $FILENAME.txt | |
| BUILD_CONF_ID=$(echo $JOBS | cut -d, -f3 | cut -d\" -f4) | |
| ARTIFACT_URL="https://ci.appveyor.com/api/buildjobs/$BUILD_CONF_ID/artifacts/erpiko.zip" | |
| echo $ARTIFACT_URL > $FILENAME.txt | |
| #### Fourth | |
| URL=$(echo $JOB_NAMES | cut -d, -f4 | cut -d\" -f4) | |
| FILENAME=$(echo $URL | sed -e "s/: //g" | sed -e "s/; //g") | |
| touch $FILENAME.txt | |
| BUILD_CONF_ID=$(echo $JOBS | cut -d, -f4 | cut -d\" -f4) | |
| ARTIFACT_URL="https://ci.appveyor.com/api/buildjobs/$BUILD_CONF_ID/artifacts/erpiko.zip" | |
| echo $ARTIFACT_URL > $FILENAME.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment