I want to execute a powershell script containing the azure cli to create blueprints in azure as a task in the azure devops. I have the ps script in Github and want to give the location of the script in the script location of the Azure CLI task. Can you please let me know how to achieve it ?
First off, the Azure CLI task is used to run a shell or batch script containing Azure CLI commands. If what you have is a PS script, go with the Azure Powershell task.
The Azure CLI/Powershell tasks have a Script Path argument, but that only accepts a fully-qualified path, or a valid path relative to the default working directory.
Although you could use wget to download the file to the agent and execute it then, it would not be suggested as you'll have the overhead of incorporating error/exception handling within the task and the pipeline. There is a Bash task available for executing scripts that you can leverage.
Hope this helps!
Related
I have multiple build and deploy pipelines for my application (User Interface, Internal APIs, External APIs, etc...). I have another build pipeline for my automated tests (which use Node JS, Nightwatch-API, Cucumber, etc..) that builds a Docker image and pushes it to the Container registry.
I want to be able to pull the testing image into my deployment pipelines and execute the appropriate test script command (i.e. npm run test:InternalAPIs). My test scripts will publish the results to a separate system. I am trying to find the best way to execute the automated testing from within the deployment pipeline.
This seems like it should be an easy task within the pipeline build, I just cannot find the task that does what I need. Any assistance would be greatly appreciated.
I'd probably write a bash script for it, and then run the script with the Bash#3 task.
Alternatively, you could make use of built in tasks, such as Docker#2 and npm#1.
Refer to Microsoft's documenation for more details.
Edit: You can create a temporary instance of the docker image with the docker run command.
I have a situation where in I need to copy set of files to a windows server through Jenkins. I see a lot of Jenkins plugins that will do this kind of job through ssh but not in my case. Jenkins is also hosted in a windows server and end server is also a windows, so I believe ssh is not an option. Any plugin available in the market to get the job done or writing our requirements in powershell/MSDos script is the only option?
Thanks in advance!
just execute a bat command with the following
copy C:\localfile.bak \\remotemachine\c$\Path\remotefile.bak
in the Using the Execute Windows batch command option in the build Step
How to run bat file in jenkins
Is it possible to call Jenkins CLI commands within a pipeline?
Upon migrating jobs to new Jenkins instances I would like to enable users to migrate their own jobs from an old Instance.
Yes, you can write pretty much any shell code you want, including calling the CLI jar from a shell instruction.
sh "java -jar /path/to/jenkins-cli.jar your-usual-command"
I am new to Jenkins, just finish to configure my first build. My question how can I run Jenkins build from my pc? I mean via command line or some script or java code, I just need to trigger it. Where do I start?
Try reading the documentation about consuming jenkins API, see the examples using curl CLI tool.
Also here's a Java API Client example for you to inspect.
I want to build my maven project in Jenkins and copy all the the jar files to a remote Unix machine.
Also I want to connect to a LDAP data Store and start the services and test if the services are up and running
Basically I want to do the following tasks after my project is successfully build in Jenkins:-
1)Copy current version of my project to designated machine and location
2)Copy configure to connect to a designated integration test DS
3)Start the services in my project
4)Test that it is running.
Can I achieve this by Publish over SSH plugin provided in jenkins??
Or Shall I create some scripts which can automate the above tasks.The reason I am asking this is because I am not very familiar with Jenkins and Unix scripting.
Is there any good approach to do this task.
Thanks in advance.
Ansia
The Publish over SSH plugin will allow you copy files to remote server and execute arbitrary commands on the remote server.
Question is - do you know how you would achieve the following on the remote server?
2)Copy configure to connect to a designated integration test DS
3)Start the services in my project
4)Test that it is running
If yes, just enter those commands into Publish over SSH configuration. Or provide a script to be executed.
If you don't know how to achieve that, then that's a separate question.
Yes, you can use the publish over ssh plugin to copy the jars, and execute a script which launches your services. Take a look here to see how to launch a script "in the background" so it does not get killed when the session ends or to avoid blocking the Jenkins build by making it wait for the script to finish executing
Can't say much about LDAP as I haven't used it but depending on your needs I guess you could create a basic helper-jar with spring-ldap or any other similar library.