It is possible to set the delay time when executing a jenkins build?
Like when using p.ex:
http://host/jenkins/job/job_name/build?delay=100sec
But making it with a plugin. I dont know how to get this delay parameter and set it with another value.
Thanks a lot.
I think build parameters are stored as environment variables and if that's the case, then you should be able set them using some code like this:
build.getEnvironment(listener).put("delay", "250");
In your plugin, you would put this in the setUp method of a class that extends the BuildWrapper.
Related
I am currently working on a project where I'd need to integrate a django application with mastodon, a federated twitter-like service.
In order to interact with Mastodon, I use Mastodon.py package: https://mastodonpy.readthedocs.io/en/stable/#
I would need to monitor events occurring to a specific mastodon account, a bot account managed by the django application, using the streaming capabilities provided by the package: https://mastodonpy.readthedocs.io/en/stable/#streaming
So I would need to call one of these stream methods in an infinite loop. But I can't figure out where I should place it in django. Is there a main loop somewhere where I could insert it?
You need to run this kind of things in the background. There are many options you can choose from to setup background processing.
I find the following quite easy to set up and it might be a good start for you.
Django Background tasks
Basically you create a function/job which should be done in background. You annotate it with special decorator to register as a task.
You can then choose when to run - in your case - you can run it repeatedly every certain amount of time ( no need for "infinite" loop in your job task).
It is database backend task queue - so you will run a process which monitors your tasks and run them in chosen times. See docs for detail.
Maybe you can create a django command,place your infinite loop in there, and let supervisor handle the daemonization
You can create a method to process whatever you want and call that method in files such as urls.py(which will get called only once when the server starts).
Infinite loops are not really recommended when working at Django,but, if you cannot make it work with a method ,a good solution would be to create a seperate thread and run your infinite loop there.
This way the Django application will keep being active and non-blocked and you will have the loop running and waiting for an event.
I honestly don't know if performance and speed wise this is a good solution but it does the job.
I'm not being able to set an environment project variable on runtime. On my workflow, I got a job that downloads the project and creates a release. I'd like to take the release number and set as an environment variable in a way that could be used later for another job on my workflow.
I've already tried to set the variable using but when the next job on the workflow runs this variable is undefined:
echo 'export TAG_VERSION="1.0.0"' >> $BASH_ENV
Unfortunately, the job where I want to use this variable is a CircleCI Orbs so there's not much I can change. Here is the link for the Orbs aws-ecr
This is the job on the workflow
- aws-ecr/build_and_push_image:
tag: ${TAG_VERSION}
...
I has customize the DefaultTemplate and change the SyncWorkspace activity to TfGet activity.
Now I'm trying to queue a build with shelve but the build seem to ignore the shelve and ran the build without the shelve, I'v tried to queue the same build with the same shelve in the default template and everything is fine..
There is anyone that know what the problem?
Did you have to use TF get activity to get the sources. There are some obvious differences between the both SyncWorkspace and Tf get activity. Recommend you to use TF get source activity. Tess pass on my environment with below settings.
Each build process template has a parameter called SupportedReasons. This enum is normally set to all. Make sure you have this parameter in your customized templated and didn't change the value.
I am looking for the console application equivalent of Application.Restart() but cannot seem to find a way to do this.
It has been suggested by others to simply call my Sub Main with Args when I need to restart. However the reason I need the functionality to physically restart the application is because the first thing I do is check for updates and install them if they any are availible.
The update technique itself works perfectly, the system installs new updates but changes do not take effect until next time the application runs obviously.
As the application is run from a batch file as a scheduled task only once a week any updates I release would not take effect for two weeks!
I had the same problem with a windows forms application however the ability to call Application.Restart allows changes to take place imediately. Can the same be achieved when creating a console application?
2 Possibilities i can think of.
First one start another instance of the application and close the current one using something like
System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
and
Environment.Exit(int exitCode)
second if it's not possible to run 2 instances at the same time for some reasons u can create another application that gets started by the batch. Make it run your application and let it get an info if the updating process is done so it can first close the current application and then run another one
For my programm to run I need system variable defited. I vant to be capable to set it and restart my app immidiatly or, if it is set do nothing. how to create such app with visual studio C++?
Use a wrapper application that sets the environment variable, then launches the main app.
Does SetEnvironmentVariable work?
First of all, it's not clear why the "restart" is necessary. The application can decide what to do based on whether environment variable is set or not, and it can also set it (SetEnvironmentVariable). Of course, you can always create a new process (CreateProcess) with your application name and end the current process, but something smells wrong with this design.