curl -s https://USER:API_TOKEIN@jenkins.prod.com:8443/jenkins/job/SCM_SVN_MODEL/config.xml | curl -X POST 'http://USER:APITOKEN@jenkins-dev.test.com:8080/jenkins/createItem?name=JOBNAME' --header "Content-Type: application/xml" -d @-
Get the API token on the target machine (in this case jenkins-dev.test.com)
- Open browser and login on target machine
- http://jenkins-dev.test.com:8080/jenkins/user/USER/configure
- hit the API TOKEN button
If you want to directly copy to a folder do this ...
curl -s https://USER_SRC:APITOKEN_SRC@jenkins.prod.com:8443/jenkins/job/SCM_SVN_MODEL/config.xml | \
curl -X POST 'http://USER_TGT:APITOKEN_TGT@jenkins-dev.test.com:8080/jenkins/job/SANDBOX/createItem?name=JOBNAME' --header "Content-Type: application/xml" -d @-
or if you have a list of them ....
declare -a arr=(
"SEFS_ABSTRACT_ACTION_MODEL"
"SEFS_ABSTRACT_BUILD_ENV_MODEL"
"SEFS_ABSTRACT_BUILD_MODEL"
"SEFS_ABSTRACT_SCM_MODEL"
"SEFS_ABSTRACT_TEST_MODEL"
"SEFS_BASE_AUX_MODEL"
"SEFS_BUILDER_TMPL"
"SEFS_JAVA_BUILD_MODEL"
"SEFS_MASTER_BUILD_TMPL"
"SEFS_PROJECT_TMPL"
"SEFS_SCM_GIT_MODEL"
"SEFS_SCM_SVN_MODEL"
"SEFS_SILVER_FABRIC_DEPLOY_TMPLT"
"SEFS_STANDARD_BUILD_ENV_MODEL"
"SEFS_TEST_JUNIT_MODEL"
"SEFS_TIBCO_BUILD_MODEL"
"SEFS_UC_DEPLOY_MODEL")
## now loop through the above array
for i in "${arr[@]}"
do
curl -s https://USERID_SRC:2615adec2asas558a20790eec2994096c3c455b43@jenkins.prod.com:8443/jenkins/job/$i/config.xml | curl -X POST "http://USERID_TGT:efd517beb69f2ca1sfasfd81371885a48a928cf565@jenkins-dev.test.com:8080/jenkins/job/SANDBOX/createItem?name=$i" --header "Content-Type: application/xml" -d @-
# or do whatever with individual element of the array
done
No comments:
Post a Comment