I'm new to the whole Azure DevOps world and just got transferred to a new team that does just that.
One of my assignments is to fix an issue with a pipeline where one of the steps runs a shell script that installs an application. Currently, the step seems to run without any issue shown on the log, but when we connect to the container's pod, the app is not there.
If we run the script directly inside the pod, the application is installed correctly. I'm not sure how to track this. One of the things I've tried was to check the event log to see if there's any error while the installation is executed:Get-Eventlog -LogNmae "Windows PowerShell" -Newest 20, so far no luck here. Again, kinda of new at this, not sure what other tools are out there to track the reason why the script is not installing during the pipeline execution.
To troubleshoot your pipeline run, you can configure your pipeline logs to be more verbose.
1, To configure verbose logs for a single run, you can start a new build by choosing Run pipeline and selecting Enable system diagnostics, Run.
2,To configure verbose logs for all runs, you can add a variable named system.debug and set its value to true.
You can also try logging into your agent server and check for the event log. See this blog for view event log on windows.
The issue was related to how the task was awaited. Adding this piped params helped us solve the issue:
RUN powershell C:\dev\myprocess.ps1 -PassThru | Wait-Process;
Related
I accidentally screwed up my darktable configuration, so I reloaded it from scratch. To avoid losing all my recorded changes I have done to my pictures, I wrote a powershell backup script for the darktable database. I want to launch this script from the windows task scheduler when ever I launch darktable. I have found the event id which indicates in the security log of a new process has occurred which I should be able to use to automatically launch my backup script from task scheduler. I want to add code to the script to check the services to see if darktable is actually running and only perform the backup if it is. Anyone know how I can identify this?
I have a notebook instance with a notebook file. I use the instance's startup script to run this notebook file using papermill.
I want the notebook file to be run only when I remotely start the instance, and not from google cloud console.
I'd like to know if one of these is possible, or if there's another solution:
1 - The script will detect that the instance was started from the dashboard.
2 - I will remove the startups script and use another script that can be run by a remote command.
3 - The shutdown script will remove the startup script.
Script definition is kept under /var/run/google.startup.script for the scenarios mentioned:
Seems complicated detect if the instance was started from the dashboard.
Is feasible to delete the startup script mentioned earlier, and run your own script remotely.
Delete the script.
Before to delete the scrip I suggest you to make a backup of it in case of any issue arises for delete it, also keep in mind that AI Platform Notebooks is a managed service, any admin configuration could cause potential issues in your instance, be careful when deleting or modifying the startup script.
My advise will be actually run a notebook via a Scheduler system, I posted here the multiple options: GCP run a prediction of a model every day
I'm looking for the best solution for automating Windows server 2012r2 via Rundeck. I'm extremely familiar with Rundeck but use it for linux vms. I've searched online for this topic but havent found anything that seems reliable. Ideally, I want to start a Runeck Job that can add users in Active Directory but not sure how to approach it. I've tried using winrm but have gotten mixed results. Ironically, it will run basic powershell commands but it errors when trying to do anything with AD. Ive even tried creating a powershell script on the AD server and have Rundeck simply execute the powershell script to no avail. Hopefully someone has had success in controlling windows nodes with Rundeck. Below is the error i receive when trying to run a powershell script.
Execution failed: 27 in project windows: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [Windows_AD_Server: NonZeroResultCode: [WinRMPython] Result code: 1 + {dataContext=MultiDataContextImpl(map={ContextView(node:Windows_AD_Server)=BaseDataContext{{exec={exitCode=1}}}, ContextView(step:1, node:Windows_AD_Server)=BaseDataContext{{exec={exitCode=1}}}}, base=null)} ]}, Node failures: {Windows_AD_Server=[NonZeroResultCode: [WinRMPython] Result code: 1 + {dataContext=MultiDataContextImpl(map={ContextView(node:Windows_AD_Server)=BaseDataContext{{exec={exitCode=1}}}, ContextView(step:1, node:Windows_AD_Server)=BaseDataContext{{exec={exitCode=1}}}}, base=null)} ]}, status: failed]
Firstly, PowerShell already offers a built-in way to execute jobs, with no 3rd party addons.
About Jobs
Provides information about how PowerShell background jobs run a command or expression in the background without interacting with the current session.
About Remote Jobs
Describes how to run background jobs on remote computers.
PowerShell Jobs Week: Remote Jobs
I've never heard of / used Rundeck as Paul points out as well, so this just be the Rundeck has particulars that need to be in play first. Yet, looking at the docs, and a quick youtube video on the topic, there are several things that must be in place for what you say here...
I've tried using winrm but have gotten mixed results.
… to work.
Video - Running commands remotely using the console with WinRM/WinRS
If Rundeck is similar to SCCM or Scheduled Task, then the same approach applies.
Write Your PowerShell script. have Rundeck/ScheduedTask call powershell.exe to run the script
How to execute a PowerShell script automatically using Windows task scheduler?
Also, this could very well be seen as a duplicate of this stackoverflow discussion and answer.
rundeck unable to execute powershell script with import-module
I am setting up somethin similar and have the same problem. The AD operation executes successfully, but returns exit code 1 and throw the error you mentioned. I am in the process of debugging the plugin, but it seems there is a bug within response handling.
Please check if the ad operation works although the error is thrown and please post the script block you are using to control the AD.
Edit: in meantime I was able to narrow down the issue and opened an issue with the project: github
I provisionally fixed the issue with adding the following line in winrm-session.py after line 89:
new_msg = msg
The line before is:
" error message: %s" % (e))
The line after is:
else:
If this does not solve your issue, please post your script block.
Best Tobias
I couldn't find much information on Google regarding this topic. Below, I have provided three results from the same Selenium tests. Why am I getting different results when running the tests from different places?
INFO:
So our architecture: Bitbucket, Bamboo Stage 1 (Build, Deploy to QA), Bamboo Stage 2 (start Amazon EC2 instance "Test", run tests from Test against recently deployed QA)
Using Chrome Webdriver.
For all three of the variations I am using the same QA URL that our application is deployed on.
I am running all tests Parallelizable per fixture
The EC2 instance is running Windows Server 2012 R2 with the Chrome browser installed
I have made sure that the test solution has been properly deployed to the EC2 "test" instance. It is indeed the exact same solution and builds correctly.
First, Local:
Second, from EC2 Via SSM Script that invokes the tests:
Note that the PowerShell script calls the nunit3-console.exe just like it would be utilized in my third example using the command line.
Lastly, RDP in on EC2 and run tests from the command line:
This has me perplexed... Any reasons why Selenium is running different on different machines?
This really should be a comment, but I can't comment yet so...
I don't know enough about the application you are testing to say for sure, but this seems like something I've seen testing the application I'm working on.
I have seen two issues. First, Selenium is checking for the element before it's created. Sometimes it works and sometimes it fails, it just depends on how quickly the page loads when the test runs. There's no rhyme or reason to it. Second, the app I'm testing is pretty dumb. When you touch a field, enter data and move on to the next, it, effectively, posts all editable fields back to the database and refreshes all the fields. So, Selenium enters the value, moves to the next field and pops either a stale element error or can't find element error depending on when in the post/refresh cycle it attempts to interact with the element.
The solution I have found is moderately ugly, I tried the wait until, but because it's the same element name, it's already visible and is grabbed immediately which returns a stale element. As a result, the only thing that I have found is that by using explicit waits between calls, I can get it to run correctly consistently. Below is an example of what I have to do with the app I'm testing. (I am aware that I can condense the code, I am working within the style manual for my company)
Thread.Sleep(2000);
By nBaseLocator = By.XPath("//*[#id='attr_seq_1240']");
IWebElement baseRate = driver.FindElement(nBaseLocator);
baseRate.SendKeys(Keys.Home + xBaseRate + Keys.Tab);
If this doesn't help, please tell us more about the app and how it's functioning so we can help you find a solution.
#Florent B. Thank you!
EDIT: This ended up not working...
The tests are still running different when called remotely with a powershell script. But, the tests are running locally on both the ec2 instance and my machine correctly.
So the headless command switch allowed me to replicate my failed tests locally.
Next I found out that a headless chrome browser is used during the tests when running via script on an EC2 instance... That is automatic, so the tests where indeed running and the errors where valid.
Finally, I figured out that the screen size is indeed the culprit as it was stuck to a size of 600/400 (600/400?)
So after many tries, the only usable screen size option for Windows, C# and ChromeDriver 2.32 is to set your webDriver options when you initiate you driver:
ChromeOptions chromeOpt = new ChromeOptions();
chromeOpt.AddArguments("--headless");
chromeOpt.AddArgument("--window-size=1920,1080");
chromeOpt.AddArguments("--disable-gpu");
webDriver = new ChromeDriver(chromeOpt);
FINISH EDIT:
Just to update
Screen size is large enough.
Still attempting to solve the issue. Anyone else ran into this?
AWS SSM Command -> Powershell -> Run Selenium Tests with Start-Process -> Any test that requires an element fails because ElementNotFound or ElementNotVisible exceptions.
Using POM for tests. FindsBy filter in c# is not finding elements.
Running tests locally on EC2 run fine from cmd, powershell and Powershell ISE.
The tests do not work correctly when executing with the AWS SSM Command. Cannot find any resources to fix problem.
I have a powershell script that runs for ~30 minutes (waiting on various process' to finish). At the end, it writes a message to the event log, determining if the process was a success or failure. I plan on hosting this script on teamcity and want the build to fail, but don't know how to handle the interaction between the script and teamcity in order for this to happen.
I'm looking for a way to make a powershell script that is ran remotely to communicate to teamcity whether it was a failure or success. I've read up on a lot of the teamcity documentation and I'm still not sure how to start going about this.
You should probably consider using TeamCity Service Messages, or specifically Reporting Build Problems.
An example of how to emit a service message using PowerShell (assuming you're using the PowerShell build step):
Write-Output "##teamcity[buildStatus text='I am a successful build']"
or
Write-Output "##teamcity[buildProblem description='$powershell_error_message']"
where you can inject the captured powershell error message.
To intentionally fail a build in teamcity you should use "[Environment] :: Exit (1)" instead of "Exit 1".
More information can be obtained at the link below:
https://confluence.jetbrains.com/display/TCD9/PowerShell