Last active
June 24, 2019 08:55
-
-
Save kentkost/700c356854d1c281c0a1c4448bd3d498 to your computer and use it in GitHub Desktop.
Jenkinsfile Linter for my bash_profile
This file contains 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
# add ~/.bash_profile if needed for executing ~/.bashrc | |
if [ -e ~/.bashrc -a ! -e ~/.bash_profile -a ! -e ~/.bash_login -a ! -e ~/.profile ]; then | |
printf "\n\033[31mWARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.\033[m\n\n" | |
echo "This looks like an incorrect setup." | |
echo "A ~/.bash_profile that loads ~/.bashrc will be created for you." | |
cat >~/.bash_profile <<-\EOF | |
# generated by Git for Windows | |
test -f ~/.profile && . ~/.profile | |
test -f ~/.bashrc && . ~/.bashrc | |
EOF | |
fi | |
echo "Profile: C:\Users\KKOS\AppData\Local\Programs\Git\etc\profile.d" | |
alias platform="cd 'C:\\Users\\KKOS\\OneDrive - Widex\\Documents\\Platform'" | |
alias hasim="cd 'C:\\Users\\KKOS\\SVN'" | |
alias np="'C:\\Program Files (x86)\\Notepad++\\notepad++.exe'" | |
alias vc="'C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe'" | |
alias config="np 'C:\Users\KKOS\AppData\Local\Programs\Git\etc\profile.d\bash_profile.sh'" | |
#Go to local working directory | |
#cd "C:/Users/KKOS/" | |
#Adding ssh key for easier to use git commands with bitbucket repo | |
eval $(ssh-agent -s) | |
ssh-add C:\\Users\\KKOS\\.ssh\\bitbucket | |
#work folder | |
#Run jenkins in a docker container from image: jenkins/jenkins | |
#>docker pull jenkins/jenkins | |
#>docker run -p 9090:8080 -p 50000:50000 --name jenkins jenkins/jenkins | |
#set up jenkins from http://localhost:9090 | |
#Run JenkinsfileLint | |
#? | |
#Profit | |
JenkinsfileLint() { | |
#Simple request | |
#curl -s --user admin:123456 -X POST -F "jenkinsfile=<Jenkinsfile" http://localhost:8080/pipeline-model-converter/validate | |
#local Jenkins url | |
#URL="http://localhost:8080/pipeline-model-converter/validate" | |
#Docker jenkins url | |
local URL="http://localhost:8080/pipeline-model-converter/validate" | |
local HTTP_RESPONSE=$(curl --silent --user kkos:jbr82rtjx6 --write-out "HTTPSTATUS:%{http_code}" -X POST -F "jenkinsfile=<Jenkinsfile" $URL) | |
# Response body | |
local HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS:.*//g') | |
# extract the status | |
local HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') | |
# print the body | |
echo "$HTTP_BODY" | |
if [ ! $HTTP_STATUS -eq 200 ]; then | |
echo "Error [HTTP status: $HTTP_STATUS]. Is there a Jenkinsfile in your directory?" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment