Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/testtools/testrunner/tools/kick_jenkins.cmd

raw
1 @REM Copyright (c) Microsoft. All rights reserved.
2 @REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 @setlocal EnableExtensions EnableDelayedExpansion
5 @echo off
6
7 set current-path=%~dp0
8
9 rem // remove trailing slash
10 set current-path=%current-path:~0,-1%
11
12 set build-root=%current-path%\..
13 rem // resolve to fully qualified path
14 for %%i in ("%build-root%") do set build-root=%%~fi
15
16 REM check that we have a valid argument
17 if "%1" equ "" (
18 set jenkins_job=_integrate-into-develop
19 ) else if /i "%1" equ "c" (
20 set jenkins_job=_integrate-into-develop-c-and-wrappers
21 ) else if /i "%1" equ "csharp" (
22 set jenkins_job=_integrate-into-develop-csharp
23 ) else if /i "%1" equ "java" (
24 set jenkins_job=_integrate-into-develop-java
25 ) else if /i "%1" equ "node" (
26 set jenkins_job=_integrate-into-develop-node
27 ) else (
28 echo Usage:
29 echo kick_jenkins
30 echo or
31 echo "kick_jenkins c | csharp | java | node"
32 exit /b 1
33 )
34
35 REM check that we have java handy
36 call :checkExists java
37 if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
38
39 REM check that jenkins-cli.jar is in the repository's tools folder
40 if not exist %build-root%\tools\jenkins-cli.jar (
41 echo jenkins-cli does not exist
42 echo Downloading from repository:
43 echo http://azure-iot-sdks-ci.westus.cloudapp.azure.com:8080/jnlpJars/jenkins-cli.jar
44
45 powershell -Command "Invoke-WebRequest http://azure-iot-sdks-ci.westus.cloudapp.azure.com:8080/jnlpJars/jenkins-cli.jar -OutFile %build-root%\tools\jenkins-cli.jar"
46
47 if not !ERRORLEVEL!==0 (
48 echo Failed downloading jenkins-cli.jar
49 echo Use the following link to manually download it into the tools folder of your repository:
50 echo http://azure-iot-sdks-ci.westus.cloudapp.azure.com:8080/jnlpJars/jenkins-cli.jar
51 exit /b 1
52 )
53 )
54
55 REM find current branch
56 for /f "usebackq tokens=*" %%i in (`git symbolic-ref -q HEAD`) do set "current_branch_ref=%%i"
57 if defined current_branch_ref set "current_branch=%current_branch_ref:refs/heads/=%"
58
59 REM handle detached HEAD
60 if not defined current_branch (
61 echo You're not on any branch! Aborting...
62 goto :eof
63 )
64
65 REM Must be on a topic branch when running this script
66 set __exit=1
67 if not "%current_branch%"=="master" if not "%current_branch%"=="develop" set __exit=0
68 if %__exit%==1 (
69 echo You cannot call this script from 'develop' or 'master'. Change to a topic branch first. Aborting...
70 goto :eof
71 )
72
73 REM find tracking branch
74 for /f "usebackq tokens=*" %%i in (`git rev-parse --symbolic-full-name --abbrev-ref @{u}`) do set "tracking_branch=%%i"
75 if not defined tracking_branch (
76 echo Branch ^'%current_branch%^' is not tracking a remote branch! First try ^'git branch -u ^<remote^>/^<branch^>^' to set tracking info. Aborting...
77 goto :eof
78 )
79
80 for /f "usebackq tokens=*" %%i in (`git config branch.%current_branch%.remote`) do set "remote=%%i"
81 if not defined remote (
82 REM should never happen...
83 echo Cannot isolate remote name for tracking branch ^'%tracking_branch%^'! Aborting...
84 goto :eof
85 )
86
87 REM get the tracking branch name only e.g., origin/topic -> topic
88 for /f "usebackq tokens=*" %%i in (`call echo %%tracking_branch:%remote%/^=%%`) do set "tracking_name=%%i"
89
90 REM find repo url
91 for /f "usebackq tokens=*" %%i in (`git ls-remote --heads --get-url %remote%`) do set "repo_url=%%i"
92 if not defined repo_url (
93 echo Cannot find the remote repository URL! Aborting...
94 goto :eof
95 )
96
97 echo ****************************************************************
98 echo commit_id: %current_branch%
99 echo repo_url: %repo_url%
100 echo remote: %remote%
101 echo trackingN: %tracking_name%
102 echo jenkinJob: %jenkins_job%
103 echo ****************************************************************
104
105
106 REM kick off the build!
107 java -jar "%build-root%"\tools\jenkins-cli.jar -s http://azure-iot-sdks-ci.westus.cloudapp.azure.com:8080/ build %jenkins_job% -p COMMIT_ID=%tracking_name% -p AZURE_REPO=%repo_url% -p BRANCH_TO_MERGE_TO=develop -s -v
108
109 rem -----------------------------------------------------------------------------
110 rem -- done
111 rem -----------------------------------------------------------------------------
112 goto :eof
113
114 rem -----------------------------------------------------------------------------
115 rem -- helper subroutines
116 rem -----------------------------------------------------------------------------
117 :checkExists
118 where %~1 >nul 2>nul
119 if not !ERRORLEVEL!==0 (
120 echo "%~1" not found. Please make sure that "%~1" is installed and available in the path.
121 exit /b !ERRORLEVEL!
122 )
123 goto :eof
124