{"id":1477,"date":"2024-05-08T12:07:44","date_gmt":"2024-05-08T04:07:44","guid":{"rendered":"http:\/\/oneai.eu.org\/?p=1477"},"modified":"2024-05-08T12:07:44","modified_gmt":"2024-05-08T04:07:44","slug":"jenkins%e5%9c%a8%e6%89%a7%e8%a1%8cshell%e4%b8%ad%e5%8f%af%e5%bc%95%e7%94%a8%e7%9a%84%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f","status":"publish","type":"post","link":"https:\/\/oneai.eu.org\/?p=1477","title":{"rendered":"jenkins\u5728\u6267\u884cshell\u4e2d\u53ef\u5f15\u7528\u7684\u73af\u5883\u53d8\u91cf"},"content":{"rendered":"<pre><code class=\"language-bash\">BUILD_NUMBER\uff0c \u552f\u4e00\u6807\u8bc6\u4e00\u6b21build\uff0c\u4f8b\u598223\uff1b\nBUILD_ID\uff0c\u57fa\u672c\u4e0a\u7b49\u540c\u4e8eBUILD_NUMBER\uff0c\u4f46\u662f\u662f\u5b57\u7b26\u4e32\uff0c\u4f8b\u59822011-11-15_16-06-21\uff1b\nJOB_NAME\uff0c job\u7684\u540d\u5b57\uff0c\u4f8b\u5982JavaHelloWorld\uff1b\nBUILD_TAG\uff0c\u4f5c\u7528\u540cBUILD_ID,BUILD_NUMBER,\u7528\u6765\u5168\u5c40\u5730\u552f\u4e00\u6807\u8bc6\u4e00\u6b64build\uff0c\u4f8b\u5982jenkins-JavaHelloWorld-23\uff1b\nEXECUTOR_NUMBER\uff0c \u4f8b\u59820\uff1b\nNODE_NAME\uff0cslave\u7684\u540d\u5b57\uff0c\u4f8b\u5982MyServer01\uff1b\nNODE_LABELS\uff0cslave\u7684label\uff0c\u6807\u8bc6slave\u7684\u7528\u5904\uff0c\u4f8b\u5982JavaHelloWorld MyServer01\uff1b\nJAVA_HOME\uff0c java\u7684home\u76ee\u5f55\uff0c\u4f8b\u5982C:\\Program Files (x86)\\Java\\jdk1.7.0_01\uff1b\nWORKSPACE\uff0cjob\u7684\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff0c\u4f8b\u5982c:\\jenkins\\workspace\\JavaHelloWorld\uff1b\nHUDSON_URL = JENKINS_URL\uff0c jenkins\u7684url\uff0c\u4f8b\u5982http:\/\/localhost:8000\/ \uff1b\nBUILD_URL\uff0cbuild\u7684url \u4f8b\u5982http:\/\/localhost:8000\/job\/JavaHelloWorld\/23\/\uff1b\nJOB_URL\uff0c job\u7684url\uff0c\u4f8b\u5982http:\/\/localhost:8000\/job\/JavaHelloWorld\/\uff1b\nSVN_REVISION\uff0csvn \u7684revison\uff0c \u4f8b\u59824\uff1b\n\u4f7f\u7528${BUILD_NUMBER}\n\nThe following variables are available to shell scripts\n\nBRANCH_NAME\nFor a multibranch project, this will be set to the name of the branch being built, for example in case you wish to deploy to production from master but not from feature branches; if corresponding to some kind of change request, the name is generally arbitrary (refer to CHANGE_ID and CHANGE_TARGET).\nCHANGE_ID\nFor a multibranch project corresponding to some kind of change request, this will be set to the change ID, such as a pull request number, if supported; else unset.\nCHANGE_URL\nFor a multibranch project corresponding to some kind of change request, this will be set to the change URL, if supported; else unset.\nCHANGE_TITLE\nFor a multibranch project corresponding to some kind of change request, this will be set to the title of the change, if supported; else unset.\nCHANGE_AUTHOR\nFor a multibranch project corresponding to some kind of change request, this will be set to the username of the author of the proposed change, if supported; else unset.\nCHANGE_AUTHOR_DISPLAY_NAME\nFor a multibranch project corresponding to some kind of change request, this will be set to the human name of the author, if supported; else unset.\nCHANGE_AUTHOR_EMAIL\nFor a multibranch project corresponding to some kind of change request, this will be set to the email address of the author, if supported; else unset.\nCHANGE_TARGET\nFor a multibranch project corresponding to some kind of change request, this will be set to the target or base branch to which the change could be merged, if supported; else unset.\nBUILD_NUMBER\nThe current build number, such as &quot;153&quot;\nBUILD_ID\nThe current build ID, identical to BUILD_NUMBER for builds created in 1.597+, but a YYYY-MM-DD_hh-mm-ss timestamp for older builds\nBUILD_DISPLAY_NAME\nThe display name of the current build, which is something like &quot;#153&quot; by default.\nJOB_NAME\nName of the project of this build, such as &quot;foo&quot; or &quot;foo\/bar&quot;.\nJOB_BASE_NAME\nShort Name of the project of this build stripping off folder paths, such as &quot;foo&quot; for &quot;bar\/foo&quot;.\nBUILD_TAG\nString of &quot;jenkins-${JOB_NAME}-${BUILD_NUMBER}&quot;. All forward slashes (\/) in the JOB_NAME are replaced with dashes (-). Convenient to put into a resource file, a jar file, etc for easier identification.\nEXECUTOR_NUMBER\nThe unique number that identifies the current executor (among executors of the same machine) that\u2019s carrying out this build. This is the number you see in the &quot;build executor status&quot;, except that the number starts from 0, not 1.\nNODE_NAME\nName of the agent if the build is on an agent, or &quot;master&quot; if run on master\nNODE_LABELS\nWhitespace-separated list of labels that the node is assigned.\nWORKSPACE\nThe absolute path of the directory assigned to the build as a workspace.\nJENKINS_HOME\nThe absolute path of the directory assigned on the master node for Jenkins to store data.\nJENKINS_URL\nFull URL of Jenkins, like http:\/\/server:port\/jenkins\/ (note: only available if Jenkins URL set in system configuration)\nBUILD_URL\nFull URL of this build, like http:\/\/server:port\/jenkins\/job\/foo\/15\/ (Jenkins URL must be set)\nJOB_URL\nFull URL of this job, like http:\/\/server:port\/jenkins\/job\/foo\/ (Jenkins URL must be set)\nGIT_COMMIT\nThe commit hash being checked out.\nGIT_PREVIOUS_COMMIT\nThe hash of the commit last built on this branch, if any.\nGIT_PREVIOUS_SUCCESSFUL_COMMIT\nThe hash of the commit last successfully built on this branch, if any.\nGIT_BRANCH\nThe remote branch name, if any.\nGIT_LOCAL_BRANCH\nThe local branch name being checked out, if applicable.\nGIT_URL\nThe remote URL. If there are multiple, will be GIT_URL_1, GIT_URL_2, etc.\nGIT_COMMITTER_NAME\nThe configured Git committer name, if any.\nGIT_AUTHOR_NAME\nThe configured Git author name, if any.\nGIT_COMMITTER_EMAIL\nThe configured Git committer email, if any.\nGIT_AUTHOR_EMAIL\nThe configured Git author email, if any.\nMERCURIAL_REVISION\nFull ID of revision checked out.\nMERCURIAL_REVISION_SHORT\nAbbreviated ID of revision checked out.\nMERCURIAL_REVISION_NUMBER\nNumber of revision checked out (not portable across clones).\nMERCURIAL_REVISION_BRANCH\nBranch of revision checked out, if not checking out by branch head.\nMERCURIAL_REPOSITORY_URL\nURL of repository.\nSVN_REVISION\nSubversion revision number that&#039;s currently checked out to the workspace, such as &quot;12345&quot;\nSVN_URL\nSubversion URL that&#039;s currently checked out to the workspace.<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>BUILD_NUMBER\uff0c \u552f\u4e00\u6807\u8bc6\u4e00\u6b21build\uff0c\u4f8b\u598223\uff1b BUILD_ID\uff0c\u57fa\u672c\u4e0a\u7b49\u540c\u4e8eBUILD_NUMBER\uff0c\u4f46\u662f\u662f\u5b57\u7b26\u4e32\uff0c\u4f8b\u59822011-11-15_16-06-21\uff1b JOB_NAME\uff0c job\u7684\u540d\u5b57\uff0c\u4f8b\u5982JavaHelloWorld\uff1b BUILD_TAG\uff0c\u4f5c\u7528\u540cBUILD_ID,BUILD_NUMBER,\u7528\u6765\u5168\u5c40\u5730\u552f\u4e00\u6807\u8bc6\u4e00\u6b64build\uff0c\u4f8b\u5982jenkins-JavaHelloWorld-23\uff1b EXECUTOR_NUMBER\uff0c \u4f8b\u59820\uff1b NODE_NAME\uff0cslave\u7684\u540d\u5b57\uff0c\u4f8b\u5982MyServer01\uff1b NODE_LABELS\uff0cslave\u7684label\uff0c\u6807\u8bc6slave\u7684\u7528\u5904\uff0c\u4f8b\u5982JavaHelloWorld MyServer01\uff1b JAVA_HOME\uff0c java\u7684home\u76ee\u5f55\uff0c\u4f8b\u5982C:\\Program Files (x86)\\Java\\jdk1.7.0_01\uff1b WORKSPACE\uff0cjob\u7684\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff0c\u4f8b\u5982c:\\jenkins\\workspace\\JavaHelloWorld\uff1b HUDSON_URL = JENKINS_URL\uff0c jenkins\u7684url\uff0c\u4f8b\u5982http:\/\/localhost:8000\/ \uff1b BUILD_URL\uff0cbuild\u7684url \u4f8b\u5982http:\/\/localhost:8000\/job\/JavaHelloWorld\/23\/\uff1b JOB_URL\uff0c job\u7684url\uff0c\u4f8b\u5982http:\/\/localhost:8000\/job\/JavaHelloWorld\/\uff1b SVN_REVISION\uff0csvn \u7684revison\uff0c \u4f8b\u59824\uff1b \u4f7f\u7528${BUILD_NUMBER} The following variables are available to shell scripts BRANCH_NAME For a multibranch project, this will be set to the name of the branch being built, for example in case you wish to deploy to production from master but not from feature branches; if corresponding to some kind of change request, the name is generally arbitrary (refer to CHANGE_ID and CHANGE_TARGET). CHANGE_ID For a multibranch project corresponding to some kind of change request, this will be set to the change ID, such as a pull request number, if supported; else unset. CHANGE_URL For a multibranch project corresponding to some kind of change request, this will be set to the change URL, if supported; else unset. CHANGE_TITLE For a multibranch project corresponding to some kind of change request, this will be set to the title of the change, if supported; else unset. CHANGE_AUTHOR For a multibranch project corresponding to some kind of change request, this will be set to the username of the author of the proposed change, if supported; else unset. CHANGE_AUTHOR_DISPLAY_NAME For a multibranch project corresponding to some kind of change request, this will be set to the human name of the author, if supported; else unset. CHANGE_AUTHOR_EMAIL For a multibranch project corresponding to some kind of change request, this will be&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[86,82],"tags":[],"class_list":["post-1477","post","type-post","status-publish","format-standard","hentry","category-jenkins","category-82"],"_links":{"self":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1477"}],"version-history":[{"count":1,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1477\/revisions"}],"predecessor-version":[{"id":1478,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1477\/revisions\/1478"}],"wp:attachment":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}