jenkins-cli

While using jenkins API, getting a failure on reconfig_job

我与影子孤独终老i 提交于 2019-12-25 04:09:57
问题 I am using jenkins rest API to recurse through jobs and then reconfigure this one. All methods work except one. He's is my code : def get_server_instance(): jenkins_url = 'xxxx' #server = Jenkins(jenkins_url, username = '', password = '') # Connect to instance - username and password are optional server = jenkins.Jenkins(jenkins_url, username = '', password = '') return server def get_job_details(): # Refer Example #1 for definition of function 'get_server_instance' server = get_server

How to set “Scan Organization Triggers” via Jenkins script console?

冷暖自知 提交于 2019-12-24 11:29:36
问题 I need a way to set “Scan Organization Triggers” via the Jenkins script console. This is close, but only shows Multibranch or Organization Scan triggers if they already exist: https://github.com/cloudbees/jenkins-scripts/blob/master/setOrgFolderIndex.groovy 回答1: Here's a script that I made that detects multibranch or organization triggers. If the project doesn't already have one, it will create a trigger. Note: the addTrigger part is commented out, so this should be safe to run as-is. import

Jenkins CLI with HTTPS

六眼飞鱼酱① 提交于 2019-12-23 08:04:21
问题 My Jenkins server was switched to now using HTTPS. However, now when trying to run jenkins-cli.jar, I get the following error: Exception in thread "main" java.io.IOException: Failed to connect to https://ncs-jenkins.cisco.com/ at hudson.cli.CLI.getCliTcpPort(CLI.java:266) at hudson.cli.CLI.<init>(CLI.java:126) at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72) at hudson.cli.CLI._main(CLI.java:466) at hudson.cli.CLI.main(CLI.java:382) Caused by: javax.net.ssl

Jenkins CLI with HTTPS

廉价感情. 提交于 2019-12-23 08:04:14
问题 My Jenkins server was switched to now using HTTPS. However, now when trying to run jenkins-cli.jar, I get the following error: Exception in thread "main" java.io.IOException: Failed to connect to https://ncs-jenkins.cisco.com/ at hudson.cli.CLI.getCliTcpPort(CLI.java:266) at hudson.cli.CLI.<init>(CLI.java:126) at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72) at hudson.cli.CLI._main(CLI.java:466) at hudson.cli.CLI.main(CLI.java:382) Caused by: javax.net.ssl

Which Jenkins Command to Get the List of Changed Files

自古美人都是妖i 提交于 2019-12-23 01:05:09
问题 In a Jenkins build I see a list of changed files: So which command Jenkins uses to get this list (I am using git for repository version control). 回答1: You can use the changeSets property of the currentBuild global variable to get information relating to the detected changes of the current build. e.g. // returns a list of changed files @NonCPS String getChangedFilesList() { changedFiles = [] for (changeLogSet in currentBuild.changeSets) { for (entry in changeLogSet.getItems()) { // for each

Which Jenkins Command to Get the List of Changed Files

匆匆过客 提交于 2019-12-23 01:04:07
问题 In a Jenkins build I see a list of changed files: So which command Jenkins uses to get this list (I am using git for repository version control). 回答1: You can use the changeSets property of the currentBuild global variable to get information relating to the detected changes of the current build. e.g. // returns a list of changed files @NonCPS String getChangedFilesList() { changedFiles = [] for (changeLogSet in currentBuild.changeSets) { for (entry in changeLogSet.getItems()) { // for each

How to restart Jenkins in Windows

China☆狼群 提交于 2019-12-22 04:48:20
问题 Not able to restart Jenkins manually. Already tried all below ways: http://localhost:8080/safeRestart Error message: Jenkins cannot restart itself as currently configured. Manage Jenkins → Restart Safely Plugin . Error message: Jenkins cannot restart itself as currently configured. Not able to find any Jenkins Service in services.msc . Navigate to jenkins-cli directory in CMD mode java -jar jenkins-cli.jar -s http://[jenkins-server]/ restart See below screenshot for error message: 回答1: Use

Is it possible to send emails from the Jenkins Script Console?

谁说我不能喝 提交于 2019-12-21 06:26:30
问题 To automate user registration in a new Jenkins instance, I have generated a Groovy script: // Automatically generated groovy script -- 1463047124 jenkins.model.Jenkins.instance.securityRealm.createAccount("username", "NGRkOGJiNGE2NDEyMTExMDI0OGZmOWNj") def user = hudson.model.User.get("username"); def userEmail = "username@domain.com"; user.addProperty(new hudson.tasks.Mailer.UserProperty(userEmail)); Then I can either paste this into the Jenkins Script Console or run it through the Jenkins

How to remotely login to a Jenkins server using Java?

我们两清 提交于 2019-12-19 11:41:19
问题 I'm trying to login remotely to a Jenkins server using Java. I didn't found some documentation on how this should be securely done. For my local server using the url: http://user:pass@server doesn't work . Can anybody recommend me some documentation regarding this topic ? 回答1: Documention from jenkins wiki Should work with your Basic Authentication type. Java example with httpclient 4.3.x import java.io.IOException; import java.net.URI; import org.apache.http.HttpHost; import org.apache.http

Jenkins-Build when a change is pushed to GitHub option is not working

眉间皱痕 提交于 2019-12-17 10:26:37
问题 Jenkins is running on localhost. I have my repository in GitHub. I have the option to 'Build when a change is pushed to GitHub' checked. When I click 'Build Now', build is done successfully, no issues there. But when am committing code to my repository, auto build is not happening. I can access GitHub from my system as the repository is public and I believe even Jenkins should be able to detect it. I know there is a polling option but I want Jenkins to build when change is detected in