Hello, I have previously used the Jenkins CLI to create a new job from a template. However, (known issue) I am unable to copy Promoted Builds steps as part of this. So I have gone down the path of trying to robocopy the template job to a new job name, and search/replace values within. For some reason Jenkins is not picking up the new job. Here are the basic steps my script is executing
1. Robocopy "\\$JenkinsServer\jobs\$TemplateJob" "
\\$JenkinsServer\jobs\$NewBuildJobName" *.* /E /XD .git /XF *.log
2. Then using Powershell: replace "##RELEASEVERSION##" flag with my new
release version (ie. v17)
3. Then using Powershell: replace "<disabled>true</disabled>" with
"<disabled>false</disabled>"
4. Then write the xml file back out to "
\\$JenkinsServer\jobs\$NewBuildJobName\config.xml"
5. I then look "\\$JenkinsServer\jobs\$jobname\promotions" and iterate
through each promotion level
6. I replace "<project>$templateJobName</project>" with
"<project>$jobname</project>"
7. I then try to use the CLI to reload-configuration (which doesn't work
for me, so I do it manually in the UI)
1. Doesn't work: java -jar ..\bin\jenkins-cli.jar -s "
http://$JenkinsServer/" reload-configuration --username $UserName
--password $Password
Once I reload configuration, Jenkins does not see and pick up the new
build. I have not been able to find any other config files where build jobs
are stored/configuration apart from the jobs folder.
One thing I have noticed through a folder compare with BeyondCompare, is
that the new files are Unicode, and not UTF-8, could have be causing my
Jenkins issues?
For fun, I have attached my script, if you have any feedback/suggestions
I'm all ears.
Assumptions:
A couple functions in the script take a parameter $JenkinsServer, which
defaults to localhost, you will need to update as per your environment.
Set these values as per your needs
$ReleaseVersion = "v1.0"
$ProjectToBuild = "MyNewProject"
You have a 'template' job created in the naming format of "template-JobName"
You run Powershell as an Admin
Thank you.
Mike
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
Functions_JenkinsAutomation2.ps1
Description: Binary data
