¡Esta es una revisión vieja del documento!
Puedes crear distintas tareas de Jenkins. Los más útiles a día de hoy:
La más fácil para mi hasta ahora es la pipeline pero escogiendo la opción “Pipeline script from SCM” que obtiene el Jenkinsfile de un SCM (SCM = gestor de código tipo Git).
Para crear un pipeline necesitarás un Jenkinsfile, para desarrollarlo tienes los siguientes consejos:
There is a Visual Studio Code extension called Jenkins runner: https://marketplace.visualstudio.com/items?itemName=dave-hagedorn.jenkins-runner
Thanks to that extension we will be able to directly run local code into a Jenkins task. However, you will need to previously configure the extension. For that, lets imagine an existent Jenkins pipeline called `testpipeline`. You would open your Visual Studio Code settings file and add the next configuration:
"jenkins-runner.hostConfigs": {
"local": {
"url": "http://127.0.0.1:8080",
"user": "your-jenkins-user",
"password": "your-password"
}
},
"jenkins-runner.jobs": {
"job-testpipeline": {
"isDefault": true,
"runWith": "local",
"name": "testpipeline",
},
}
Locally you would create a Jenkinsfile like this example:
pipeline {
agent any
stages {
stage ('Initialize') {
steps {
echo 'Hello Jenkins!'
}
}
}
}
If we do ctrl+shift+p there will appear a menu where we can select Jenkins runner: Run pipeline script on a default job. Doing that you should see what Jenkins says in the same Visual Studio Code output window.