Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57314

P4 Sync to label after sync to head without deleting non labeled files

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • p4-plugin
    • linux

      I've created a perforce workspace and I've sync it to the head version.

      However I would like to sync the same workspace to a label but without deleting files that are not in the label. Like running the command p4 sync <workspace>/... @=label . 

      I've tried many combinations of the populate command but all of them have run something like  p4 sync <arguments><workspace>/... @label 

      Is there a way to run the p4sync command on jenkins so that it run a p4 sync ** @= command?*

       

      Thanks!

          [JENKINS-57314] P4 Sync to label after sync to head without deleting non labeled files

          Chris Carr added a comment - - edited

          I'm hitting the same problem - I've been experimenting with using the P4 object to sync to a small subset of the stream we are building on, on the master. Using p4sync with the same credentials works correctly, but creating a p4 object and then syncing fails with "ERROR: P4: Task Exception: Invalid credentials". Unfortunately it's not practical to fully sync to our streams on the master, as they are quite large.

          Chris Carr added a comment - - edited I'm hitting the same problem - I've been experimenting with using the P4 object to sync to a small subset of the stream we are building on, on the master. Using p4sync with the same credentials works correctly, but creating a p4 object and then syncing fails with "ERROR: P4: Task Exception: Invalid credentials". Unfortunately it's not practical to fully sync to our streams on the master, as they are quite large.

          Karl Wirth added a comment -

          Hi both. I hit this invalid credentials when there was a typo in my credential ID. Can you please try the following simple code test to see if it works for you. Please replace 'JenkinsMaster' with the name of your Perforce credential ID and '//depot/Jam/...' with a small path in your depot:

          def p4SyncLabel(String credential, String ws_name, String ws_view, String label, boolean append, boolean force){
                  echo "In function ..."
                  def ws = [$class: 'ManualWorkspaceImpl', name: ws_name, spec: [view: ws_view]]
                  def p4 = p4(credential: credential, workspace: ws)
                  p4.run('sync')
                  echo "... function end"
          }
          
          pipeline {
           agent {
              label 'master'
           }
           options {
              timestamps()
           }
           stages {
              stage('Test') {
                 steps{
                    echo 'Test'
                    script{
                       p4SyncLabel('JenkinsMaster', "jenkins_${NODE_NAME}_${JOB_BASE_NAME}_${EXECUTOR_NUMBER}",
                                    "//depot/Jam/... //jenkins_${NODE_NAME}_${JOB_BASE_NAME}_${EXECUTOR_NUMBER}/...",
                                   'head', true, false )
                    }
                  }
                }
             }
          }
          

           

          Karl Wirth added a comment - Hi both. I hit this invalid credentials when there was a typo in my credential ID. Can you please try the following simple code test to see if it works for you. Please replace 'JenkinsMaster' with the name of your Perforce credential ID and '//depot/Jam/...' with a small path in your depot: def p4SyncLabel( String credential, String ws_name, String ws_view, String label, boolean append, boolean force){ echo "In function ..." def ws = [$class: 'ManualWorkspaceImpl' , name: ws_name, spec: [view: ws_view]] def p4 = p4(credential: credential, workspace: ws) p4.run( 'sync' ) echo "... function end" } pipeline { agent { label 'master' } options { timestamps() } stages { stage( 'Test' ) { steps{ echo 'Test' script{ p4SyncLabel( 'JenkinsMaster' , "jenkins_${NODE_NAME}_${JOB_BASE_NAME}_${EXECUTOR_NUMBER}" , " //depot/Jam/... //jenkins_${NODE_NAME}_${JOB_BASE_NAME}_${EXECUTOR_NUMBER}/..." , 'head' , true , false ) } } } } }  

          Chris Carr added a comment - - edited

          Hi . I ran the job, and it failed with the output below.

          I double checked the credentials name, and it was correct (and it's using the same credentials with a P4Sync call that has no problems). We're on version 1.9.6 of the Jenkins plugin, but plan on updating to 1.10.0 very shortly.

           

          -------

          Started by user ccarr
          Running in Durability level: MAX_SURVIVABILITY
          [Pipeline] Start of Pipeline
          [Pipeline] node
          Running on Jenkins in /var/lib/jenkins/workspace/Project/Test_P4Jenkins
          [Pipeline] {
          [Pipeline] timestamps
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Test)
          [Pipeline] echo
          18:37:36 Test
          [Pipeline] script
          [Pipeline]

          { [Pipeline] echo 18:37:36 In function ... [Pipeline] p4 [Pipeline] }

          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // timestamps
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: P4: Task Exception: Invalid credentials
          Finished: FAILURE

          Chris Carr added a comment - - edited Hi . I ran the job, and it failed with the output below. I double checked the credentials name, and it was correct (and it's using the same credentials with a P4Sync call that has no problems). We're on version 1.9.6 of the Jenkins plugin, but plan on updating to 1.10.0 very shortly.   ------- Started by user ccarr Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/lib/jenkins/workspace/Project/Test_P4Jenkins [Pipeline] { [Pipeline] timestamps [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] echo 18:37:36 Test [Pipeline] script [Pipeline] { [Pipeline] echo 18:37:36 In function ... [Pipeline] p4 [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // timestamps [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: P4: Task Exception: Invalid credentials Finished: FAILURE

          Jose Valverde added a comment -

          Hi Karl!

           

          I'm having the same issue as mentioned above.

          And we are also using version 1.9.6!

           
           
          Running in Durability level: MAX_SURVIVABILITY[Pipeline] Start of Pipeline[Pipeline] node....[Pipeline] {[Pipeline] timestamps[Pipeline] {[Pipeline] stage[Pipeline] { (Test)[Pipeline] echo*09:20:51* Test[Pipeline] script[Pipeline]

          {[Pipeline] echo*09:20:51* In function ...[Pipeline] p4[Pipeline] }

          [Pipeline] // script[Pipeline] }[Pipeline] // stage[Pipeline] }[Pipeline] // timestamps[Pipeline] }[Pipeline] // node[Pipeline] End of PipelineERROR: P4: Task Exception: Invalid credentials
          Finished: FAILURE

          Jose Valverde added a comment - Hi Karl!   I'm having the same issue as mentioned above. And we are also using version 1.9.6!     Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] node.... [Pipeline] { [Pipeline] timestamps [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] echo*09:20:51* Test [Pipeline] script [Pipeline] {[Pipeline] echo*09:20:51* In function ...[Pipeline] p4[Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // timestamps [Pipeline] } [Pipeline] // node [Pipeline] End of PipelineERROR: P4: Task Exception: Invalid credentials Finished: FAILURE

          Chris Carr added a comment -

          We've updated the p4 plugin to 1.10.1, and the issue still persists. I also tried adding a p4sync() call, using the same credentials string to do a preview sync in the same job. It worked fine, so the credentials are definitely okay.

          Chris Carr added a comment - We've updated the p4 plugin to 1.10.1, and the issue still persists. I also tried adding a p4sync() call, using the same credentials string to do a preview sync in the same job. It worked fine, so the credentials are definitely okay.

          Karl Wirth added a comment -

          Hi chriscarr, citylife4

          I'd like to setup a webex with one of you to investigate further. Can one of you comment in this case then send an email to support@perforce.com so I can arrange that.

           

          Note: 1.0.2 just shipped today but as far as I know it has no credential related fixes.

           

          Thanks in advance.

           

          Karl

          Karl Wirth added a comment - Hi chriscarr , citylife4 I'd like to setup a webex with one of you to investigate further. Can one of you comment in this case then send an email to support@perforce.com so I can arrange that.   Note: 1.0.2 just shipped today but as far as I know it has no credential related fixes.   Thanks in advance.   Karl

          Karl Wirth added a comment -

          Hi chriscarr, citylife4,

          I just wanted to check in again to see if either of you are available for a webex during UK working hours?

          Karl Wirth added a comment - Hi chriscarr , citylife4 , I just wanted to check in again to see if either of you are available for a webex during UK working hours?

          Jose Valverde added a comment -

          Hi p4karl,

           

          Are you available to schedule a webex for next Monday (July 22) at 4PM UK time?

          I'm going to send the email to support@perforce.com now! 

           

          Thanks!

          Jose Valverde added a comment - Hi p4karl ,   Are you available to schedule a webex for next Monday (July 22) at 4PM UK time? I'm going to send the email to support@perforce.com  now!    Thanks!

          Karl Wirth added a comment -

          Hi citylife4 - Perfect. Thanks.

          Karl Wirth added a comment - Hi citylife4 - Perfect. Thanks.

          Frederico Pratas added a comment - - edited

          Hi,

          After some digging with joel_brown and p4karl we (citylife4 and I) managed to isolate and reproduce the credential issue.

          Another bug has been created to track this JENKINS-58745

          chriscarr you may want to follow up in case the issue matches your setup as well.

          Thanks,

          Frederico

          Frederico Pratas added a comment - - edited Hi, After some digging with  joel_brown  and p4karl  we ( citylife4 and I) managed to isolate and reproduce the credential issue. Another bug has been created to track this  JENKINS-58745 chriscarr you may want to follow up in case the issue matches your setup as well. Thanks, Frederico

            p4karl Karl Wirth
            citylife4 Jose Valverde
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: