I have a requirement to upload the build artifacts to SharePoint at the end of the build. using jenkins pipeline.
I didn't find any plugin to achieve this.
My Jenkins instance is running on a Linux machine. Please suggest the best way to achieve this
I am using CLI for Microsoft 365 for this (available for linux as well). Looks somewhat like this:
m365 login --authType password --userName user#contoso.com --password pass#word1
m365 spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg'
https://pnp.github.io/cli-microsoft365/cmd/login/
https://pnp.github.io/cli-microsoft365/cmd/spo/file/file-add/
You may need to add special account to your sharepoint for your jenkins, or add an app password to be able to upload file from a daemon process (if your sharepoint requires MFA authentication)
Related
My company is using Jenkins for their CI and so far we've only been using it for our web apps, but now we're getting to the windows service apps we use and I'm looking for some guidance on this.
Currently we have a batch script that shuts down the service then do an Hg update and then turns the service back on.
I need Jenkins to run it as admin so that windows will allow the script to toggle the services.
My question is, how hard is it for Jenkins to run something with elevated privileges?
With PsService you can execute a remote command (start/stop/restart) and provide a username and a password for elevated access.
Once you manage to do this all you need to do is to "write that line" in jenkins. Meaning that if you use pipeline you'll do it with credentials binding. Of course you need to create jenkins credentials with the aforementioned username and password.
Is there a way to add global tool configurations for artifactory and aws in jenkins through cli?
I'm trying to write chef cookbook for automating creation of Jenkins job, but I don't know how to add credentials for tools.
Credentials don't depend on the tools which will use them.
You can register credentials in general through the JENKINS Credentials Plugin API: see for instance
How to create jenkins credentials via the REST API? (similar to jenkins_api_client issue 162)
update Jenkins credentials by script
You can then use those credentials in association with a Jenkins Job.
Your question is twofold.
Credentials
The Jenkins chef cookbook offers a jenkins_credentials resource, which allows you to pipe credentials (using Jenkins API internally) into your Jenkins instance.
Global Tool Configuration
You can use the jenkins_script resource of the same cookbook to execute any Groovy script. This allows you to configure your Jenkins instance. You now just have to figure out exactly, what the code is to, e.g., select the previously defined credentials. But the code looks similarly to the example given in the cookbook's README.
Many times I have the need to download files (e.g. archives) from a remote repository (e.g. maven-repo) which is protected by username/password.
Its easy to get such a file with curl or wget, but when I don't like to see the password on the logs, maybe there is a better/embedded way to do this from within a jenkins workflow? And how do I combine it with credentials managed by jenkins credential plugin?
Use the Credentials Binding plugin, which integrates with Workflow.
We are using Hudson as a CI tool. At present we are needed to use Jenkins, to deploy the build to Stage, Prod environment. What is the best aproach we should follow.
I know about promote buld plugin, but the issue is authentication. I want whevener we need to promote a build to deploy to Stage or Prod, it should ask for netqwork credential first. And then the promote job should execute the Batch command using the creadential supplied. At present, the promote plugin, runs using the credentials which the Tomcat server is configured to run.
Same issue with Build Pipeline plugin.
I want only dev or even hudson admin also should not be able to execute the promote build unless credential supplied. (We have windows 2008 r2 OS)
Can you please help me in resolving the issue. so that basically whenever a user click on Promote build to QA\Stage\Prod the plugin should ask for credential or should use the logged on users credential and execute the batch script using the logged users credential only and not by using the credentials of the account with which the tomcat server is configured.
Can you please help me?
Please suggests us the best aproach for making automated build on prod\stage.
For deployment I normally use SSH, Private/Public keys takes care of the authentication problems normally associated with running commands on other servers.
SSH is normally associated with unix based systems, but it does support windows.
Finally, I would recommend considering decoupling your build system (jenkins) from the system performing the deployment by using an intermediate repository. See the following answer for more details:
Jenkins : how to check out artifact from Nexus and Deploy on Tomcat-
We a new gerrit 2.2.1 server using LDAP authentication in our corporate environment. We also have a Jenkins server running as a local UNIX jenkins user that I want to get check in with gerrit and post build results into gerrit.
We don't have a "jenkins" LDAP account, and even if we did, the systems group doesn't give out passwords for system accounts, so I can't go into the web UI, create the account and add jenkins' publich ssh key. How I can add a "jenkins" account to gerrit that Jenkins can use? We already have a number of people registered in Gerrit, so I need to be careful with any operations.
A little more Google searching found Paulo Pires's blog post, which led to using Gerrit's create-account command.